Layer feed function and constructor

This commit is contained in:
LeLeLeLeto
2024-12-31 01:34:56 +01:00
parent 02f0c8eac7
commit 25fe960caf

24
layer.h
View File

@ -19,8 +19,32 @@ class Layer {
inline void Forward(); // Forward Pass with sigmoid inline void Forward(); // Forward Pass with sigmoid
inline void Forward(float (*activation)(float)); // Forward Pass with custom activation function inline void Forward(float (*activation)(float)); // Forward Pass with custom activation function
inline void Feed(Matrix);
// Constructors
// Input size, Size
Layer(int, int);
}; };
Layer::Layer(int input_size, int size){
this->input = Matrix(input_size, 1);
this->weights = Matrix(input_size, size);
this->weights.Randomize(0.0F, 1.0F);
// Z, A and B are the same size as A
this->raw_output = this->input;
this->activated_output = this->input;
this->biases = this->input;
this->biases.Randomize(0.0F, 1.0F);
}
void Layer::Feed(Matrix a){
this->input = a;
}
float Layer::Sigmoid(float x){ float Layer::Sigmoid(float x){
return 1 / (1 + exp(-x)); return 1 / (1 + exp(-x));
} }