Hi there,
I have been trying to figure out how I am getting this error:
Exception in thread "main" java.lang.NumberFormatException
at java.math.BigDecimal.<init>(BigDecimal.java:368)
at java.math.BigDecimal.<init>(BigDecimal.java:647)
at newtonsMethod1.sigmoidActivationFunction(newtonsMethod1.java:118)
at newtonsMethod1.feedForward(newtonsMethod1.java:136)
The following code :
for(int j =0; j< a; j++)
{
System.out.println("Enter into input neuron "+ j);
String r = in.readLine();
Double qq = Double.parseDouble(r);
BigDecimal rr = new BigDecimal(qq);
targetInput[i][j] = rr;
if(j == a - 1){
System.out.println("Enter the desired output for it");
for(int n = 0; n < c; n++){
String p = in.readLine();
Double q = Double.parseDouble(p);
desiredOut[i][n]=q;}}
}
}
System.out.println();
System.out.println();
int pee = 0;
while( pee < f)
{
for(int i = 0; i< e; i++)
{
//test.buildWeightMatrix();
test.feedForward(i, targetInput);
//test.backwardComputation();
//test.updateWeights();
}
pee++;
}
calls the method feedForward() which is in another class. The method feedForward() is as shown belown:
public BigDecimal sigmoidActivationFunction(BigDecimal sum)
{
Big_pi test2 = new Big_pi();
BigDecimal Set = test2.exp(new BigDecimal("-sum"));
Set = Set .setScale(20,RoundingMode.HALF_UP);
return Set;
}
public void feedForward(int m, BigDecimal [][] input)
{
int i, j;
BigDecimal sum;
for(i = 0; i < hiddenNeurons; i++)
{
sum = new BigDecimal("0");
for(j = 0; j < inputNeurons; j++)
sum = (sum .add (hiddenToInputWeight[i][j] .multiply(input[m][j])));
hiddenA[i] = sigmoidActivationFunction(sum);
}
System.out.println("These are the activations of the hidden neurons:");
System.out.println();
for( i = 0; i< hiddenA.length; i++)
{System.out.println(hiddenA[i]);
System.out.println();}
System.out.println();
for(i = 0; i < outputNeurons; i++)
{
sum = new BigDecimal("0");
for(j = 0; j < hiddenNeurons; j++)
sum = sum.add(outputToHiddenWeight[i][j].multiply (hiddenA[j]));
targetOutputA[i] = sum;
}
System.out.println("This is the target output of the network:");
System.out.println();
for( i = 0; i< targetOutputA.length; i++)
System.out.println(targetOutputA[i]);
System.out.println();
}
Can you figure what I am doing wrong, each time the feedForward method is called, please?