If you want to create a very basic and simple neural network start with perceptron (Single Layer Perceptron). It only contains one neuron (node with activation function) and the weights are the same size as your input features.
I have written a simple perceptron inspired by Tsoding channel in v: perceptron, which differentiates between a circle and a rectangle.
Everything comes to the matrix when creating even a simple neural network, so if you look at the below code itβs written in the vlang but you will still be able to understand core logic.
module matrix
pub type Matrix = [][]f64module perceptron
import matrix { Matrix }
pub struct Perceptron {
mut:
// simple matrix to store the weights
weights Matrix
}
// simple function that just multiply features with weights and return the sum
pub fn (p Perceptron) feed_forward(inputs Matrix) f64 {
mut output := 0.0
for i in 0 .. inputs.len {
for j in 0 .. inputs[0].len {
output += inputs[i][j] * p.weights[i][j]
}
}
return output
}