giagrad.nn#
Cotainers#
Base class for all neural network modules. |
|
A sequential container. |
Linear Layers#
Densely-connected Neural Network layer: \(y = xA^T + b\). |
Dropout Layers#
Randomly sets some of the input tensor elements to zero during training using a Bernoulli distribution with a probability of |
|
Randomly zeroes a specific dimension of the input tensor with probability |
Convolution Layers#
1D convolution layer. |
|
2D convolution layer. |
|
3D convolution layer. |
Normalization Layers#
Applies Batch Normalization as described in Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift . |
|
Applies Layer Normalization over a mini-batch of inputs as described in the paper Layer Normalization |
Loss Functions#
Computes the cross entropy loss between input logits and target. |
Activations#
Unlike the activation functions already implemented as methods in the
giagrad.Tensor
, there are also classes that, on their own, have
the same behavior as their homologous methods in giagrad.Tensor
.
Thet are useful when creating modules such as Sequential:
import giagrad.nn as nn
model = nn.Sequential(
nn.Linear(128, 40),
nn.LeakyReLU(neg_slope=3),
nn.Dropout(0.4),
nn.Linear(40, 10)
)
They behave like callable classes:
activation = nn.SiLU(alpha=0.5)
t = Tensor.empty(2, 3).uniform(-10, 10)
activation(t)
Applies the Rectified Linear Unit (ReLU) function element-wise. |
|
Applies a modified version of ReLU with maximum size of 6. |
|
Applies the hardswish function, element-wise. |
|
Applies the element-wise function \(\text{Sigmoid}(x) = \frac{1}{1 + \exp(-x)}\) |
|
Applies the Exponential Linear Unit (ELU) function element-wise. |
|
Applies the Sigmoid Linear Unit (SiLU) function, element-wise. |
|
Applies the hyperbolic tangent function element-wise. |
|
Applies element-wise \(\text{LeakyReLU}(x) = \max(0, x) + \text{negative_slope} * \min(0, x)\). |
|
Applies element-wise \(\text{SoftPlus}(x) = \frac{1}{\text{beta}} \cdot \log(1 + \exp(\text{beta} \times data_i))\). |
|
Applies Mish activation function element-wise. |
|
Applies element-wise the function \(\text{GELU}(x) = x \times \Phi(x)\). |
|
Applies \(\text{GELU}(x) = x \times \Phi(x)\) activation function with SiLU approximation. |
|
Applies the softmax function through 1-D slices specified by |
|
Applies the logsoftmax function through 1-D slices specified by |