From 25fe960caf30f04e174ba12a3b607d97f805bcf4 Mon Sep 17 00:00:00 2001 From: LeLeLeLeto Date: Tue, 31 Dec 2024 01:34:56 +0100 Subject: [PATCH] Layer feed function and constructor --- layer.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/layer.h b/layer.h index 5563ebe..3ac8fe0 100644 --- a/layer.h +++ b/layer.h @@ -19,8 +19,32 @@ class Layer { inline void Forward(); // Forward Pass with sigmoid 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){ return 1 / (1 + exp(-x)); }