solidc
Robust collection of general-purpose cross-platform C libraries and data structures designed for rapid and safe development in C
Loading...
Searching...
No Matches
Classes | Functions
ml.h File Reference

Simple Machine Learning library using 4x4 Matrices and Vectors. More...

#include "matrix.h"
#include "vec.h"
Include dependency graph for ml.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ML_Layer
 Represents a single fully connected layer 4 inputs -> 4 outputs. More...
 
struct  ML_Network
 A neural network composed of multiple layers. More...
 

Functions

void ml_init (ML_Network *net, int num_layers, float learning_rate)
 Initialize a new network.
 
Vec4 ml_forward (ML_Network *net, Vec4 input)
 Perform forward propagation.
 
float ml_train_step (ML_Network *net, Vec4 input, Vec4 target)
 Train the network on a single sample.
 

Detailed Description

Simple Machine Learning library using 4x4 Matrices and Vectors.

Demonstrates a real-world use case for the vector and matrix libraries. Implements a simple Feed-Forward Neural Network (MLP) with Sigmoid activation.

Limitations:

Definition in file ml.h.

Function Documentation

◆ ml_forward()

Vec4 ml_forward ( ML_Network net,
Vec4  input 
)

Perform forward propagation.

Parameters
netPointer to the network.
inputInput vector (4 floats).
Returns
Output vector (4 floats).

Definition at line 47 of file ml.c.

References ml_forward().

Referenced by ml_forward(), and ml_train_step().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ml_init()

void ml_init ( ML_Network net,
int  num_layers,
float  learning_rate 
)

Initialize a new network.

Parameters
netPointer to the network struct.
num_layersNumber of layers to create.
learning_rateLearning rate for gradient descent.

Definition at line 36 of file ml.c.

References ml_init().

Referenced by ml_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ml_train_step()

float ml_train_step ( ML_Network net,
Vec4  input,
Vec4  target 
)

Train the network on a single sample.

Parameters
netPointer to the network.
inputInput vector.
targetTarget output vector.
Returns
MSE Loss for this sample.

Definition at line 74 of file ml.c.

References ml_forward(), ml_train_step(), Vec4::w, Vec4::x, Vec4::y, and Vec4::z.

Referenced by ml_train_step().

Here is the call graph for this function:
Here is the caller graph for this function: