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 [source] ΒΆ
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 [source] ΒΆ
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.