Interface Layer
- All Known Implementing Classes:
ActivationFunction, AdaptiveAvgPool2dLayer, AvgPool2dLayer, BatchNorm1dLayer, BatchNorm2dLayer, Conv2dLayer, Conv2dNormActivation, DropoutLayer, EfficientNet, EmbeddingLayer, FusedMBConv, GELU, GLU, GroupNormLayer, HardShrink, LayerBlock, LeakyReLU, LinearLayer, LogSigmoid, LogSoftmax, MaxPool2dLayer, MBConv, PositionalEncoding, ReLU, RMSNormLayer, SequentialBlock, Sigmoid, SiLU, Softmax, SoftShrink, SqueezeExcitation, StochasticDepth, Tanh, TanhShrink, Transformer
-
Method Summary
Modifier and TypeMethodDescriptionstatic AdaptiveAvgPool2dLayeradaptiveAvgPool2d(int size) Returns an adaptive average pooling layer.default Tensororg.bytedeco.pytorch.ModuleasTorch()Returns the PyTorch Module object.static AvgPool2dLayeravgPool2d(int size) Returns an average pooling layer that reduces a tensor by combining cells, and assigning the average value of the input cells to the output cell.static BatchNorm1dLayerbatchNorm1d(int in) Returns a normalization layer that re-centers and normalizes the output of one layer before feeding it to another.static BatchNorm1dLayerbatchNorm1d(int in, double eps, double momentum, boolean affine) Returns a normalization layer that re-centers and normalizes the output of one layer before feeding it to another.static BatchNorm2dLayerbatchNorm2d(int in) Returns a normalization layer that re-centers and normalizes the output of one layer before feeding it to another.static BatchNorm2dLayerbatchNorm2d(int in, double eps, double momentum, boolean affine) Returns a normalization layer that re-centers and normalizes the output of one layer before feeding it to another.static Conv2dLayerconv2d(int in, int out, int kernel) Returns a convolutional layer.static Conv2dLayerconv2d(int in, int out, int kernel, int stride, int padding, int dilation, int groups, boolean bias, String paddingMode) Returns a convolutional layer.static Conv2dLayerconv2d(int in, int out, int size, int stride, String padding, int dilation, int groups, boolean bias, String paddingMode) Returns a convolutional layer.static DropoutLayerdropout(double p) Returns a dropout layer that randomly zeroes some of the elements of the input tensor with probability p during training.static EmbeddingLayerembedding(int numTokens, int dim) Returns an embedding layer that is a simple lookup table that stores embeddings of a fixed dictionary and size.static EmbeddingLayerembedding(int numTokens, int dim, double alpha) Returns an embedding layer that is a simple lookup table that stores embeddings of a fixed dictionary and size.Forward propagation (or forward pass) through the layer.static SequentialBlockgelu(int in, int out) Returns a fully connected layer with GELU activation function.static SequentialBlockgelu(int in, int out, double dropout) Returns a fully connected layer with GELU activation function.static SequentialBlockhardShrink(int in, int out) Returns a fully connected layer with hard shrink activation function.static SequentialBlockleaky(int in, int out, double negativeSlope) Returns a fully connected layer with leaky ReLU activation function.static SequentialBlockleaky(int in, int out, double negativeSlope, double dropout) Returns a fully connected layer with leaky ReLU activation function.static LinearLayerlinear(int in, int out) Returns a linear fully connected layer.static SequentialBlocklogSigmoid(int in, int out) Returns a fully connected layer with log sigmoid activation function.static SequentialBlocklogSoftmax(int in, int out) Returns a fully connected layer with log softmax activation function.static MaxPool2dLayermaxPool2d(int size) Returns a max pooling layer that reduces a tensor by combining cells, and assigning the maximum value of the input cells to the output cell.static SequentialBlockrelu(int in, int out) Returns a fully connected layer with ReLU activation function.static SequentialBlockrelu(int in, int out, double dropout) Returns a fully connected layer with ReLU activation function.static SequentialBlocksigmoid(int in, int out) Returns a fully connected layer with sigmoid activation function.static SequentialBlocksilu(int in, int out) Returns a fully connected layer with SiLU activation function.static SequentialBlocksilu(int in, int out, double dropout) Returns a fully connected layer with SiLU activation function.static SequentialBlocksoftmax(int in, int out) Returns a fully connected layer with softmax activation function.static SequentialBlocksoftShrink(int in, int out) Returns a fully connected layer with soft shrink activation function.static SequentialBlocktanh(int in, int out) Returns a fully connected layer with tanh activation function.static SequentialBlocktanhShrink(int in, int out) Returns a fully connected layer with tanh shrink activation function.default LayerMoves the layer block to a device.default Layerto(Device device, ScalarType dtype) Moves the layer block to a device.
-
Method Details
-
forward
-
apply
-
asTorch
org.bytedeco.pytorch.Module asTorch()Returns the PyTorch Module object.- Returns:
- the PyTorch Module object.
-
to
-
to
Moves the layer block to a device.- Parameters:
device- the compute device.dtype- the data type.- Returns:
- this layer.
-
linear
Returns a linear fully connected layer.- Parameters:
in- the number of input features.out- the number of output features.- Returns:
- a fully connected layer.
-
relu
Returns a fully connected layer with ReLU activation function.- Parameters:
in- the number of input features.out- the number of output features.- Returns:
- a fully connected layer.
-
relu
Returns a fully connected layer with ReLU activation function.- Parameters:
in- the number of input features.out- the number of output features.dropout- the optional dropout probability.- Returns:
- a fully connected layer.
-
leaky
Returns a fully connected layer with leaky ReLU activation function.- Parameters:
in- the number of input features.out- the number of output features.negativeSlope- Controls the angle of the negative slope in leaky ReLU, which is used for negative input values.- Returns:
- a fully connected layer.
-
leaky
Returns a fully connected layer with leaky ReLU activation function.- Parameters:
in- the number of input features.out- the number of output features.negativeSlope- Controls the angle of the negative slope in leaky ReLU, which is used for negative input values.dropout- the optional dropout probability.- Returns:
- a fully connected layer.
-
gelu
Returns a fully connected layer with GELU activation function.- Parameters:
in- the number of input features.out- the number of output features.- Returns:
- a fully connected layer.
-
gelu
Returns a fully connected layer with GELU activation function.- Parameters:
in- the number of input features.out- the number of output features.dropout- the optional dropout probability.- Returns:
- a fully connected layer.
-
silu
Returns a fully connected layer with SiLU activation function.- Parameters:
in- the number of input features.out- the number of output features.- Returns:
- a fully connected layer.
-
silu
Returns a fully connected layer with SiLU activation function.- Parameters:
in- the number of input features.out- the number of output features.dropout- the optional dropout probability.- Returns:
- a fully connected layer.
-
tanh
Returns a fully connected layer with tanh activation function.- Parameters:
in- the number of input features.out- the number of output features.- Returns:
- a fully connected layer.
-
sigmoid
Returns a fully connected layer with sigmoid activation function.- Parameters:
in- the number of input features.out- the number of output features.- Returns:
- a fully connected layer.
-
logSigmoid
Returns a fully connected layer with log sigmoid activation function.- Parameters:
in- the number of input features.out- the number of output features.- Returns:
- a fully connected layer.
-
softmax
Returns a fully connected layer with softmax activation function.- Parameters:
in- the number of input features.out- the number of output features.- Returns:
- a fully connected layer.
-
logSoftmax
Returns a fully connected layer with log softmax activation function.- Parameters:
in- the number of input features.out- the number of output features.- Returns:
- a fully connected layer.
-
tanhShrink
Returns a fully connected layer with tanh shrink activation function.- Parameters:
in- the number of input features.out- the number of output features.- Returns:
- a fully connected layer.
-
softShrink
Returns a fully connected layer with soft shrink activation function.- Parameters:
in- the number of input features.out- the number of output features.- Returns:
- a fully connected layer.
-
hardShrink
Returns a fully connected layer with hard shrink activation function.- Parameters:
in- the number of input features.out- the number of output features.- Returns:
- a fully connected layer.
-
conv2d
Returns a convolutional layer.- Parameters:
in- the number of input channels.out- the number of output features.kernel- the window/kernel size.- Returns:
- a convolutional layer.
-
conv2d
static Conv2dLayer conv2d(int in, int out, int kernel, int stride, int padding, int dilation, int groups, boolean bias, String paddingMode) Returns a convolutional layer.- Parameters:
in- the number of input channels.out- the number of output channels/features.kernel- the window/kernel size.stride- controls the stride for the cross-correlation.padding- controls the amount of padding applied on both sides.dilation- controls the spacing between the kernel points.groups- controls the connections between inputs and outputs. The in channels and out channels must both be divisible by groups.bias- If true, adds a learnable bias to the output.paddingMode- "zeros", "reflect", "replicate" or "circular".- Returns:
- a convolutional layer.
-
conv2d
static Conv2dLayer conv2d(int in, int out, int size, int stride, String padding, int dilation, int groups, boolean bias, String paddingMode) Returns a convolutional layer.- Parameters:
in- the number of input channels.out- the number of output channels/features.size- the window/kernel size.stride- controls the stride for the cross-correlation.padding- "valid" or "same". With "valid" padding, there's no "made-up" padding inputs. It drops the right-most columns (or bottom-most rows). "same" tries to pad evenly left and right, but if the amount of columns to be added is odd, it will add the extra column to the right. If stride is 1, the layer's outputs will have the same spatial dimensions as its inputs.dilation- controls the spacing between the kernel points.groups- controls the connections between inputs and outputs. The in channels and out channels must both be divisible by groups.bias- If true, adds a learnable bias to the output.paddingMode- "zeros", "reflect", "replicate" or "circular".- Returns:
- a convolutional layer.
-
maxPool2d
Returns a max pooling layer that reduces a tensor by combining cells, and assigning the maximum value of the input cells to the output cell.- Parameters:
size- the window/kernel size.- Returns:
- a max pooling layer.
-
avgPool2d
Returns an average pooling layer that reduces a tensor by combining cells, and assigning the average value of the input cells to the output cell.- Parameters:
size- the window/kernel size.- Returns:
- a max pooling layer.
-
adaptiveAvgPool2d
Returns an adaptive average pooling layer.- Parameters:
size- the output size.- Returns:
- an adaptive average pooling layer.
-
batchNorm1d
Returns a normalization layer that re-centers and normalizes the output of one layer before feeding it to another. Centering and scaling the intermediate tensors has a number of beneficial effects, such as allowing higher learning rates without exploding/vanishing gradients.- Parameters:
in- the number of input features.- Returns:
- a normalization layer.
-
batchNorm1d
Returns a normalization layer that re-centers and normalizes the output of one layer before feeding it to another. Centering and scaling the intermediate tensors has a number of beneficial effects, such as allowing higher learning rates without exploding/vanishing gradients.- Parameters:
in- the number of input features.eps- a value added to the denominator for numerical stability.momentum- the value used for the running_mean and running_var computation. Can be set to 0.0 for cumulative moving average (i.e. simple average).affine- when set to true, this layer has learnable affine parameters.- Returns:
- a normalization layer.
-
batchNorm2d
Returns a normalization layer that re-centers and normalizes the output of one layer before feeding it to another. Centering and scaling the intermediate tensors has a number of beneficial effects, such as allowing higher learning rates without exploding/vanishing gradients.- Parameters:
in- the number of input features.- Returns:
- a normalization layer.
-
batchNorm2d
Returns a normalization layer that re-centers and normalizes the output of one layer before feeding it to another. Centering and scaling the intermediate tensors has a number of beneficial effects, such as allowing higher learning rates without exploding/vanishing gradients.- Parameters:
in- the number of input features.eps- a value added to the denominator for numerical stability.momentum- the value used for the running_mean and running_var computation. Can be set to 0.0 for cumulative moving average (i.e. simple average).affine- when set to true, this layer has learnable affine parameters.- Returns:
- a normalization layer.
-
dropout
Returns a dropout layer that randomly zeroes some of the elements of the input tensor with probability p during training. The zeroed elements are chosen independently for each forward call and are sampled from a Bernoulli distribution. Each channel will be zeroed out independently on every forward call.This has proven to be an effective technique for regularization and preventing the co-adaptation of neurons as described in the paper "Improving Neural Networks by Preventing Co-adaptation of Feature Detectors".
- Parameters:
p- the probability of an element to be zeroed.- Returns:
- a dropout layer.
-
embedding
Returns an embedding layer that is a simple lookup table that stores embeddings of a fixed dictionary and size.This layer is often used to store word embeddings and retrieve them using indices. The input to the module is a list of indices, and the output is the corresponding word embeddings.
- Parameters:
numTokens- the size of the dictionary of embeddings.dim- the size of each embedding vector.- Returns:
- a dropout layer.
-
embedding
Returns an embedding layer that is a simple lookup table that stores embeddings of a fixed dictionary and size.This layer is often used to store word embeddings and retrieve them using indices. The input to the module is a list of indices, and the output is the corresponding word embeddings.
- Parameters:
numTokens- the size of the dictionary of embeddings.dim- the size of each embedding vector.alpha- optional scaling factor.- Returns:
- a dropout layer.
-