Layer feed function and constructor
This commit is contained in:
24
layer.h
24
layer.h
@ -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));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user