|
micrograd 0.1.0
Small C implementation of micrograd
|
Neural network layer construction, evaluation, and parameters. More...
Data Structures | |
| struct | mg_layer |
| Layer of neurons in a neural network. More... | |
Functions | |
| bool | mg_layer_init (mg_graph *g, mg_layer *l, size_t n_in, size_t n_out, bool non_linear) |
| Initialize a layer. | |
| bool | mg_layer_call (mg_graph *g, mg_layer *l, mg_value **x, mg_value **out) |
| Evaluate a layer with the given input values. | |
| void | mg_layer_free (mg_layer *l) |
| Free memory owned by a layer. | |
| size_t | mg_layer_param_count (const mg_layer *l) |
| Get the number of trainable parameters in a layer. | |
| void | mg_layer_params (const mg_layer *l, mg_value **out) |
| Copy a layer's parameters into a flat array. | |
Neural network layer construction, evaluation, and parameters.
Evaluate a layer with the given input values.
On failure, the graph is left unchanged and every out entry written by this call is reset to NULL.
| g | Graph that owns any intermediate and output values. |
| l | Layer to evaluate. |
| x | Array of l->n_in input values. |
| out | Output array with at least l->n_out entries. |
true on success, false on invalid input or allocation failure. | void mg_layer_free | ( | mg_layer * | l | ) |
Free memory owned by a layer.
| l | Layer to free. |
Initialize a layer.
| g | Graph that owns the layer's values. |
| l | Layer to initialize. |
| n_in | Number of input values consumed by each neuron. |
| n_out | Number of output values produced by the layer. |
| non_linear | Whether each neuron should use a non-linear activation function. |
true on success, false on allocation failure. | size_t mg_layer_param_count | ( | const mg_layer * | l | ) |
Get the number of trainable parameters in a layer.
| l | Layer to inspect. |