A neural network transforms numbers through weighted sums and nonlinear functions. This simulation exposes a network with two inputs, three hidden neurons, and one output. Adjust the inputs to inspect the calculation, choose a target, and run a training step to change the weights.
The forward pass
Each neuron combines its inputs with weights and a bias. For one layer, the operation is:
Here we distinguish the hidden activation from the sigmoid output:
The forward pass evaluates these operations in order. Changing an input changes the sums, activations, and prediction while keeping the weights fixed. Training is a separate operation.
● Positive contribution ● Negative contribution
Edge thickness shows |weight × source activation|. Node intensity shows activation magnitude, saturating at 1. The output always uses sigmoid. On small screens, scroll the diagram horizontally.
- Prediction ŷ
- 0.5746
- Loss ½(ŷ − t)²
- 0.0254
- Training steps
- 0
Adjust the inputs, choose a target, and train on this example.
Inspect calculations and weights
| Neuron | z | Activation | Weights | Bias |
|---|---|---|---|---|
| h1 | ||||
| h2 | ||||
| h3 | ||||
| ŷ |
Sigmoid and ReLU
Sigmoid maps any real number to a value between zero and one. ReLU preserves positive values and sets negative values to zero:
The selector changes the three hidden neurons. The output always uses sigmoid. Node intensity represents activation, while connections show the magnitude and sign of the contribution , not a probability or causal explanation. Changing an input’s sign can change the contribution’s sign even if its weight remains unchanged.
One gradient-descent step
For a target , the loss on this example is:
The button computes derivatives using backpropagation and updates both layers’ weights and biases simultaneously. If the chosen learning rate fails to reduce the loss, it tries a smaller step. The interface reports the loss before and after the update and the effective learning rate. ReLU uses a zero derivative at the origin; an inactive neuron can receive a zero gradient.
Each click trains on the visible example, not on a dataset. A lower loss here does not demonstrate generalization. Reset restores the initial inputs, weights, and target so the experiment can be repeated.