Build and train neural networks with Torch7's nn package. Use when creating MLPs, CNNs, RNNs, or custom layers in Lua/Torch. Covers modules, containers, criterions, transfer functions, convolutions, and training workflows.
Build and train neural networks using Torch7's modular nn package. Networks are composed of Modules connected via Containers, optimized using Criterions.
| Concept | Purpose | Key Classes |
|---|---|---|
| Module | Base building block | nn.Module, nn.Linear, nn.Tanh |
| Container | Compose modules | nn.Sequential, nn.Parallel, nn.Concat |
| Criterion | Loss function | nn.MSECriterion, nn.ClassNLLCriterion |
| Transfer | Non-linearity | , , |
nn.ReLUnn.Sigmoidnn.Tanhrequire "nn"
mlp = nn.Sequential()