can you help, please

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Mar 2008
Posts: 19
Reputation: debee is an unknown quantity at this point 
Solved Threads: 0
debee debee is offline Offline
Newbie Poster

can you help, please

 
0
  #1
Mar 5th, 2008
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?
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,477
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 514
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: can you help, please

 
0
  #2
Mar 5th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 19
Reputation: debee is an unknown quantity at this point 
Solved Threads: 0
debee debee is offline Offline
Newbie Poster

Re: can you help, please

 
0
  #3
Mar 5th, 2008
You are right indeed. I took a second look at all the arrays in that piece of code, and I found out that there is one which the length is supposed to be more than one, and which I have mistakenly made to be one. Thank you very much for your advice.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC