MicrogradEx.NN (MicrogradEx v0.1.0)

Copy Markdown View Source

Public facade for the tiny neural-network library.

The modules below intentionally match the scope of original micrograd: Neuron, Layer, and MLP. There are no tensors, optimizers, batching primitives, or GPU kernels. The purpose is to make backpropagation visible.

Because models are immutable, training code uses this rhythm:

loss = ...
gradients = MicrogradEx.Value.backward(loss)
model = MicrogradEx.NN.apply_gradients(model, gradients, 0.05)

That is the Elixir equivalent of loss.backward(); p.data += -lr * p.grad.

Summary

Functions

Applies one stochastic-gradient-descent style update and returns a new model.

Runs a model forward.

Counts trainable parameters.

Returns trainable parameters from any neural-network module.

Types

Functions

apply_gradients(model, gradients, learning_rate)

Applies one stochastic-gradient-descent style update and returns a new model.

learning_rate is the positive step size usually called lr in training loops. The update rule is:

new_parameter = parameter - learning_rate * gradient

forward(neuron, inputs)

Runs a model forward.

parameter_count(model)

Counts trainable parameters.

parameters(neuron)

Returns trainable parameters from any neural-network module.