Class LinearLayer
java.lang.Object
smile.deep.layer.ModuleLayer
smile.deep.layer.LinearLayer
A fully connected linear layer.
-
Constructor Summary
ConstructorsConstructorDescriptionLinearLayer(int in, int out) Constructor.LinearLayer(int in, int out, boolean bias) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionForward propagation (or forward pass) through the layer.static LinearLayergemm(int in, int out, boolean bias) A linear layer for a projection that a quantized backend may replace: identical to the constructor, except insideParameterInit.placeholderGemms()where only a 1x1 placeholder is allocated.weight()The weight[out, in]as an alias of the module parameter (shares storage; do not close it before the layer is done with).Methods inherited from class ModuleLayer
close, module, toString
-
Constructor Details
-
LinearLayer
public LinearLayer(int in, int out) Constructor.- Parameters:
in- the number of input features.out- the number of output features.
-
LinearLayer
public LinearLayer(int in, int out, boolean bias) Constructor.- Parameters:
in- the number of input features.out- the number of output features.bias- If false, the layer will not learn an additive bias.
-
-
Method Details
-
gemm
A linear layer for a projection that a quantized backend may replace: identical to the constructor, except insideParameterInit.placeholderGemms()where only a 1x1 placeholder is allocated.- Parameters:
in- the number of input features.out- the number of output features.bias- whether the layer has a bias.- Returns:
- the layer.
-
forward
-
weight
The weight[out, in]as an alias of the module parameter (shares storage; do not close it before the layer is done with).- Returns:
- the weight, or
nullwhen the native binding is unavailable.
-