Hello I am writing an algorithm for back propagation in c++, it consists of 1 input layer 1 hidden layer and 1 output layer. I am curious how to initialize my inputlayer, hiddenlayer, and outputlayer.
This is what i got:
struct Neuron {
double activation;
double bias;
double *incomingWeights;
};
struct Network {
double *targetLayer;
Neuron *inputLayer;
Neuron *hiddenLayer;
Neuron *outputLayer;
};
ann.inputLayer = malloc(din * sizeof * Neuron); //ERROR
for (int i = 0; i < din; i++) {
ann.inputLayer[i].activation = 0;
ann.inputLayer[i].bias = 0;
ann.inputLayer[i].incomingWeights = NULL;
}
ann.outputLayer = malloc(dout * sizeof * Neuron); //ERROR
for (int i = 0; i < dout; i++) {
ann.outputLayer[i].activation = 0;
ann.outputLayer[i].bias = 0;
ann.outputLayer[i].incomingWeights = new double[dhid];
}
din represents the number of neurons in my input layer. dhid represents the number of neurons in my hidden layer. dout repreesnts the number of neurons in my output layer. i didnt bother showing the initialization of my hidden layer cause its not important thank you
i wrote //ERROR on the lines where errors are shown according to my IDE(netbeans)