| | |
can you help, please
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Mar 2008
Posts: 19
Reputation:
Solved Threads: 0
Hi everyone,
Could any one help me with this code, please. I do not know why it's giving this kind of error. The code, which is a part of a lager program, is as given below. I will try explaining what each variables represent.
public void backwardComputation(int m, Double desiredOutput[][])
{
int i, j = 0;
deltaOutput[j] = (1 * (desiredOutput[m][j] - targetOutputA[j]));
System.out.println(deltaOutput[j]);
for(i = 0; i < hiddenNeurons; i++)
for(j = 0; j < outputNeurons; j++)
deltaHidden[i]=((hiddenA[i]*(1 - hiddenA[i]))*(deltaOutput[j] * outputToHiddenWeight[i][j]));
}
Let us say the variables outputNeurons and hiddenNeurons are given as 1 and 3 respectively, but each time i attempt to store ((hiddenA[i]*(1 - hiddenA[i]))*(deltaOutput[j] * outputToHiddenWeight[i][j])); into the array deltaHidden[i], it gives an error "Exception in thread "main" java.lang.ArrayIndexOutOfBoundExceptions: 1" and I have checked that the array deltaHidden[] have enough spaces, and that all other arrays in the equation work out fine. Can you help looking into this please?
Could any one help me with this code, please. I do not know why it's giving this kind of error. The code, which is a part of a lager program, is as given below. I will try explaining what each variables represent.
public void backwardComputation(int m, Double desiredOutput[][])
{
int i, j = 0;
deltaOutput[j] = (1 * (desiredOutput[m][j] - targetOutputA[j]));
System.out.println(deltaOutput[j]);
for(i = 0; i < hiddenNeurons; i++)
for(j = 0; j < outputNeurons; j++)
deltaHidden[i]=((hiddenA[i]*(1 - hiddenA[i]))*(deltaOutput[j] * outputToHiddenWeight[i][j]));
}
Let us say the variables outputNeurons and hiddenNeurons are given as 1 and 3 respectively, but each time i attempt to store ((hiddenA[i]*(1 - hiddenA[i]))*(deltaOutput[j] * outputToHiddenWeight[i][j])); into the array deltaHidden[i], it gives an error "Exception in thread "main" java.lang.ArrayIndexOutOfBoundExceptions: 1" and I have checked that the array deltaHidden[] have enough spaces, and that all other arrays in the equation work out fine. Can you help looking into this please?
No, not really, because you only posted a fragment of code that cannot be run and your indexes are going to vary at runtime. It's very simple for you to find the problem on your own though. Check your array sizes before you access them. Obviously one of those arrays only has a single element and you are trying to access a second.
![]() |
Other Threads in the Java Forum
- Previous Thread: Image Array Issue..... Any ideas???
- Next Thread: Simple problem
| Thread Tools | Search this Thread |
actuate android api applet application applications array arrays automation balls bank binary bluetooth business chat class classes clear client code codesnippet collections component coordinates database defaultmethod development dice dragging ebook eclipse educational error formatingtextintooltipjava fractal game givemetehcodez graphics gui hql html ide image infinite ingres input integer internet invokingapacheantprogrammatically j2me java javaprojects jni jpanel jtextarea julia linux list loop looping map method methods mobile mysql netbeans newbie openjavafx parameter php print problem program programming project recursion repositories scanner screen scrollbar server set size sms sort sorting sql sqlserver state storm string sun superclass swing swt text-file threads tree websites windows






