FusedLinear¶
- class paddle.incubate.nn. FusedLinear ( in_features, out_features, weight_attr=None, bias_attr=None, transpose_weight=False, name=None ) [source]
-
Linear layer takes only one multi-dimensional tensor as input with the shape \([batch\_size, *, in\_features]\) , where \(*\) means any number of additional dimensions. It multiplies input tensor with the weight (a 2-D tensor of shape \([in\_features, out\_features]\) ) and produces an output tensor of shape \([batch\_size, *, out\_features]\) . If \(bias\_attr\) is not False, the bias (a 1-D tensor of shape \([out\_features]\) ) will be created and added to the output.
- Parameters
-
in_features (int) – The number of input units.
out_features (int) – The number of output units.
weight_attr (ParamAttr, optional) – The attribute for the learnable weight of this layer. The default value is None and the weight will be initialized to zero. For detailed information, please refer to paddle.ParamAttr.
transpose_weight (bool) – Whether to transpose the weight Tensor before multiplication.
bias_attr (ParamAttr|bool, optional) – The attribute for the learnable bias of this layer. If it is set to False, no bias will be added to the output. If it is set to None or one kind of ParamAttr, a bias parameter will be created according to ParamAttr. For detailed information, please refer to paddle.ParamAttr. The default value is None and the bias will be initialized to zero.
name (str, optional) – Normally there is no need for user to set this parameter. For detailed information, please refer to Name .
- Attribute:
-
weight (Parameter): the learnable weight of this layer.
bias (Parameter): the learnable bias of this layer.
- Shape:
-
input: Multi-dimensional tensor with shape \([batch\_size, *, in\_features]\) .
output: Multi-dimensional tensor with shape \([batch\_size, *, out\_features]\) .
Examples
>>> >>> import paddle >>> paddle.device.set_device('gpu') >>> from paddle.incubate.nn import FusedLinear >>> x = paddle.randn([3, 4]) >>> linear = FusedLinear(4, 5) >>> y = linear(x) >>> print(y.shape) [3, 5]
-
forward
(
input
)
forward¶
-
Defines the computation performed at every call. Should be overridden by all subclasses.
- Parameters
-
*inputs (tuple) – unpacked tuple arguments
**kwargs (dict) – unpacked dict arguments