Overview
TheModule class is the base class for all neural network modules in Neurenix. It provides parameter management, training/evaluation modes, and hierarchical organization of submodules.
Class Definition
Core Methods
forward
Any
Input arguments to the module.
Any
Keyword arguments to the module.
Any
Output of the forward pass.
call
forward().
Parameter Management
register_parameter
str
required
The name of the parameter.
Optional[Tensor]
required
The parameter tensor, or None to remove the parameter.
register_module
str
required
The name of the submodule.
Optional[Module]
required
The submodule, or None to remove the submodule.
register_buffer
str
required
The name of the buffer.
Optional[Tensor]
required
The tensor to register as buffer, or None to remove the buffer.
parameters
List[Tensor]
A list of all parameter tensors.
Training Mode
train
bool
default:"True"
Whether to set training mode (True) or evaluation mode (False).
Module
The module itself.
eval
Module
The module itself.
is_training
bool
True if the module is in training mode, False otherwise.
Device Management
to
Device
required
The device to move to.
Module
The module itself.
clone
Module
A new module with the same parameters.
Example Usage
Built-in Modules
Neurenix provides many built-in modules:- Linear layers:
Linear - Convolutional layers:
Conv1d,Conv2d,Conv3d - Recurrent layers:
RNN,LSTM,GRU - Activation functions:
ReLU,Sigmoid,Tanh,Softmax - Pooling layers:
MaxPool2d - Regularization:
Dropout - Containers:
Sequential