identity_remainder
Bases: remainder
The identity remainder function.
It calculates the identity remainder, and returns input data as the remainders. This class inherits from the base remainder class (i.e., the remainder class in the module directory).
...
Notes
The identity remainder function \(\pi: {R}^m \to {R}^n\) just projects all inputs to the inputs themselves, i.e., $$ \begin{equation} \pi(\mathbf{x}) = \mathbf{x} \in {R}^n, \end{equation} $$ where the input and output dimensions need to be equal, i.e., \(m = n\).
By default, the remainder term will also be processed with the optional activation functions.
Attributes:
Name | Type | Description |
---|---|---|
name |
str, default = 'identity_remainder'
|
Name of the identity remainder function. |
Methods:
Name | Description |
---|---|
__init__ |
It initializes the identity remainder function. |
forward |
It implements the abstract forward method declared in the base remainder class. |
Source code in tinybig/remainder/basic_remainder.py
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 |
|
__init__(name='identity_remainder', *args, **kwargs)
The initialization method of the identity remainder function.
It initializes an identity remainder function object. This method will also call the initialization method of the base class as well.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
Name of the identity remainder function. |
'identity_remainder'
|
Returns:
Type | Description |
---|---|
remainder
|
The identity remainder function object. |
Source code in tinybig/remainder/basic_remainder.py
forward(x, device='cpu', *args, **kwargs)
The forward method of the identity remainder function.
The identity remainder function \(\pi: {R}^m \to {R}^n\) just projects all inputs to the inputs themselves, i.e., $$ \begin{equation} \pi(\mathbf{x}) = \mathbf{x} \in {R}^n, \end{equation} $$ where the input and output dimensions need to be equal, i.e., \(m = n\).
By default, the remainder term will also be processed with the optional activation functions.
Parameters
x: torch.Tensor The input data vector. device: str, default = 'cpu' Device to calculate the remainder function.
Returns
torch.Tensor The remainder term of length \(n\).