Overview
Neurenix provides a comprehensive neural network API based on theModule class, similar to PyTorch’s nn.Module. Build complex architectures by composing layers, activation functions, and custom modules.
Module Base Class
All neural network components inherit fromModule, which provides parameter management, training/evaluation modes, and device placement.
Creating Custom Modules
Module Methods
- Training Mode
- Parameters
- Device Placement
Linear Layers
Fully connected (dense) layers for transforming tensor dimensions.Linear layers use Kaiming initialization by default, which is optimal for ReLU activations.
Linear Layer with Custom dtype
Activation Functions
Neurenix provides all standard activation functions asModule subclasses.
- ReLU Variants
- Sigmoid & Tanh
- Softmax & GELU
In-Place Activations
Convolutional Layers
Neurenix supports 1D, 2D, and 3D convolutions for processing sequential, image, and volumetric data.Conv2d for Image Processing
Advanced Convolution Options
Sequential Container
Chain modules together for quick model building.- List of Modules
- Named Modules
- Indexing & Slicing
Loss Functions
All loss functions inherit from theLoss base class and support different reduction modes.
Classification Losses
Regression Losses
Reduction Modes
Complete Training Example
Model Inspection
Best Practices
Use Sequential for Simple Models
Sequential is perfect for feed-forward architectures without branching
Custom Module for Complex Logic
Implement custom Module subclasses when you need control flow or multiple paths
Remember train/eval Modes
Always call
.train() and .eval() to properly configure layers like DropoutMove Model and Data Together
Ensure both model and input tensors are on the same device
Related Documentation
- Tensors - Working with tensor operations
- Devices - Managing hardware placement
- Architecture - Understanding the framework design