RUST Essentials Intermediate

Multilayer MLP

How an MLP solves nonlinear tasks using hidden layers and backpropagation, with XOR as an example.

Premium · 7h 44m · 6 ch
Practice →
Multilayer MLP cover

What you'll build

We will build a complete neural network—a multilayer perceptron (MLP)—from scratch in Rust. Starting with the mathematical foundations of activation functions, we will gradually create layers with const generics, connect them into a network, and implement the complete training algorithm with backpropagation.

Along the way, we will see why a single perceptron cannot learn XOR, how hidden layers create nonlinear decision boundaries, and how gradient descent adjusts weights to minimize loss. In the end, our MLP will be able to learn nonlinear functions—something a single-layer perceptron cannot do.

Learning objectives

✓Understand the role of activation functions in neural networks
✓Implement a generic neural network layer with const generics
✓Build a multilayer perceptron with hidden and output layers
✓Implement backpropagation with gradient descent training
✓Train the network on the XOR function

Prerequisites

▸Basic Rust syntax (structs, traits, generics)
▸Familiarity with iterators and closures in Rust
▸Basic understanding of linear algebra (vectors, dot products)

Course curriculum

1 Activation Functions
—Activation Function Crate and Trait
—Sigmoid
—Testing the Sigmoid
—Activation Function Derivative
2 Neural Layer
—Layer with an Activation Function
—Layer Weights and Biases
—Layer Forward Pass
—Testing the Forward Pass
3 Layer as a Perceptron
—Layer Integration Test
—Layer Training Function
—Testing the Trained Layer
4 Two-Layer Network
—Network Structure
—Creating the Network
—Network Forward Pass
—Network Prediction
5 Network Training
—Network Training Method
—Test for the XOR Task
—Network Training Loop
—Loss Function
—Monitoring Training
—Layer Activation Derivative
—Output Layer Delta
—Hidden Layer Delta
—Network Backward Pass
—Updating Network Weights
6 Other Activation Functions
—The ReLU Function
—Testing ReLU
—Hyperbolic Tangent
—Testing Tanh

Technologies

Rust Neural network Multilayer perceptron Backpropagation Activation function Gradient descent Sigmoid ReLU Tanh Const generics

FAQ

Is this a video course?

No. You work through the project step by step in your browser, and the reference code for each step saves to your disk — yours to run and keep locally.

Do I need to install anything?

No. The playground runs entirely in your browser — no toolchain or local setup required.

Can I try it before subscribing?

Yes. Preview steps are available without a subscription so you can see the format and quality first.

What do I get with full access?

Every step unlocked, the Workbench app, a snapshot for each step, jump-to-any-step navigation, and all new playground releases.

Does it work with an AI agent like Claude or Codex?

Yes. You can work through a playground solo or alongside an AI agent.

Is there reference code?

Yes. Every step has a complete reference solution you can compare against.

Newsletter

New playgrounds in your inbox

Get an email when a new playground drops, plus the occasional engineering deep-dive. No spam, unsubscribe anytime.