affine
Per-channel affine transformation as a function and a learnable module.
Classes:
-
Affine–Applies an affine transformation to the input.
Functions:
-
affine–Apply a per-channel affine transformation \(y = x \cdot \text{weight} + \text{bias}\).
Affine
¶
Affine(
num_features: int,
bias: bool = True,
device: Optional[device] = None,
dtype: Optional[dtype] = None,
)
Bases: Module
Applies an affine transformation to the input. This layer will apply the following transformation to the input tensor \(x\):
Parameters:
-
num_features(int) –The number of features in the input.
-
bias(bool, default:True) –Whether to use bias.
-
device(Optional[device], default:None) –The device to use.
-
dtype(Optional[dtype], default:None) –The dtype to use.
Shape
- Input: \((N, *, C)\) where \(*\) means any number of additional dimensions.
- Output: \((N, *, C)\) where \(*\) means any number of additional dimensions.
affine
¶
Apply a per-channel affine transformation \(y = x \cdot \text{weight} + \text{bias}\).
Parameters:
-
x(Tensor) –Input tensor.
-
weight(Tensor) –Per-channel scale, broadcastable against
x. -
bias(Optional[Tensor], default:None) –Optional per-channel offset, broadcastable against
x.Noneskips the addition.
Returns:
-
Tensor–The transformed tensor, same shape as
x.
Shape
Input: \((N, *, C)\) where \(*\) means any number of additional dimensions. Output: \((N, *, C)\), same as the input.