MicrogradEx.NN.MLP (MicrogradEx v0.1.0)

Copy Markdown View Source

A multi-layer perceptron composed of Layer structs.

This is the Elixir counterpart of micrograd.nn.MLP. Hidden layers use ReLU neurons and the final layer is linear, matching the original implementation.

Summary

Functions

Runs a forward pass through all layers.

Returns all trainable parameters in layer order.

Types

t()

@type t() :: %MicrogradEx.NN.MLP{layers: [MicrogradEx.NN.Layer.t()]}

Functions

forward(mlp, inputs)

Runs a forward pass through all layers.

The final result follows original micrograd ergonomics: a one-output MLP returns a single Value, while a multi-output MLP returns a list.

new(input_count, output_counts, opts \\ [])

Creates an MLP.

input_count is the number of scalar input features. output_counts is the list of layer widths, for example [16, 16, 1] for two hidden layers and one scalar output.

parameters(mlp)

Returns all trainable parameters in layer order.