alright, well you asked for it :P
Code:
void MLP::Learn(int numegs, double testset[], double lrate)
{
int ct=0;
int i=0;
int egct=0;
double sserr=0;
double * outputs = new double [numegs];
LinActNode ** Inputs = NULL;
int NumInputs = 0;
double * Weights = NULL;
double * Invec = NULL;
for (ct=0; ct<NumOutput; ct++)
{
i = NumInput+ct; //use i rather than that expression, space saving
//Nodes[i]->blah;
Inputs = Nodes[i]->GetInputs();
NumInputs = Nodes[i]->GetNumInputs();
Weights = new double [NumInputs];
Invec = new double [NumInputs];
for (egct=0; egct<numegs; egct++)
{
cout << "Example " << egct << endl;
//Load the input nodes with the example set egct
Calculate (&testset[egct*3], outputs);
//calculate the delta value of the output nod and store it
Nodes[i]->SetDelta( testset[egct*3+2] - Nodes[i]->NodeOutput() );
cout << "Delta set to: " << Nodes[i]->GetDelta() << endl;
//get the current weights for the input to this node
Weights = Nodes[i]->GetWeights();
//Invec[] is the array of values getting passed into the node
//invec 0 is the bias term
Invec[0] = Weights[0];
cout << "Invec[0] = " << Invec[0] << endl;
for (int vecct=1; vecct<=NumInputs; vecct++)
{
//calculate invect as (output from all input nodes) * (weight associated)
Invec[vecct] = Inputs[vecct-1] -> NodeOutput() * Weights[vecct];
//cout << "Inputs[" << vecct-1 << "]->NodeOutput() = " << Inputs[vecct-1]->NodeOutput() << endl;
cout << "Invec[" << vecct << "] = " << Invec[vecct] << endl;
}
for (int wct=0; wct<=NumInputs; wct++)
{
//update the weights for the node
Weights[wct] = Weights[wct] + ( lrate * Invec[wct] * Nodes[i]->GetDelta() );
cout << "Weights["<<wct<<"] = " << Weights[wct] << endl;
}
//set the weights for the node
Nodes[i]->SetWeights(Weights);
cout << endl;
}
}
}
i understand that it probably wont make much sense but any offers you could give as to why it spews out -1.#IND after i call that a few times would be appreciated (it accumulates to that value, numbers getting increasingly large or small).
thanks a lot.