Skip to main content

Overview

Neurenix provides a comprehensive neural network API based on the Module 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 from Module, which provides parameter management, training/evaluation modes, and device placement.

Creating Custom Modules

Module Methods

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 as Module subclasses.

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.

Loss Functions

All loss functions inherit from the Loss 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 Dropout

Move Model and Data Together

Ensure both model and input tensors are on the same device
  • Tensors - Working with tensor operations
  • Devices - Managing hardware placement
  • Architecture - Understanding the framework design