MicrogradEx.NN.Layer (MicrogradEx v0.1.0)

Copy Markdown View Source

A layer is a list of neurons with the same input width.

The original Python Layer.__call__ returns a single Value when the layer has one neuron and a list otherwise. This module keeps that convenience in forward/2, and also exposes forward_many/2 so MLP can pass lists between layers consistently.

Summary

Functions

Runs the layer and unwraps singleton output layers.

Runs the layer and always returns a list of output values.

Creates a layer with output_count neurons.

Returns all trainable parameters in neuron order.

Types

t()

@type t() :: %MicrogradEx.NN.Layer{neurons: [MicrogradEx.NN.Neuron.t()]}

Functions

forward(layer, inputs)

Runs the layer and unwraps singleton output layers.

forward_many(layer, inputs)

Runs the layer and always returns a list of output values.

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

Creates a layer with output_count neurons.

Options are forwarded to each neuron. :seed is consumed once and advanced across all weights, so deterministic layers do not repeat identical neurons.

parameters(layer)

Returns all trainable parameters in neuron order.