Download Design and Implementation of a Portable Neural Network Interpreter
Transcript
for (int i = 0; i<3; i++)
skipToken(tstream);
// read and store all the weights and thesholds of the nH hidden neurons
this.hidden = new Neuron [nH];
for (int j=0; j<nH; j++){
//Read the weights & biasf values for j Neurons.
double [] weights= new double [nI];
for (int k=0; k<nI; k++){
weights[k] = getDouble(tstream);
}
bias = getDouble(tstream);
ny = new Neuron(weights, bias);
NeuronCount ++;
hidden[j]= ny;
}
System.out.println(NeuronCount + " so far.");
// read and store all the weights and bias values of the nO output neurons
this.output = new Neuron [nO];
for (int m=0; m<nO; m++){
//Read the weights & bias values for m Neurons.
double [] weights= new double [nH];
for (int n=0; n<nH; n++){
weights[n] = getDouble(tstream);
}
bias = getDouble(tstream);
ny1 = new Neuron(weights, bias);
NeuronCount ++;
output[m]= ny1;
}
infile.close();
System.out.println(NeuronCount + " at the end.");
}
/*Method for calculating output from network on receiving input from one
windowfull of input or corresponding to evaluation of one input string position*/
public double[] computeOutput (double[] input){
//input table is calculated from network’s total inalph*window size.
double[] resH = new double[nH];
double[] resO = new double[nO];
//first compute the total output from hidden neuron layer into []resH
for (int v=0; v<resH.length; v++){
resH[v] = hidden[v].calOutput(input);
}
114