NYCPHP Meetup

2D array

Tracy tech_learner at yahoo.com
Tue Mar 25 01:08:04 EST 2003


Hi,
below are few lines from a PASCAL code

PROCEDURE init;
 VAR i, n:integer;
 BEGIN
  FOR i:=1 TO numhidden DO
   BEGIN
    hiddenA[i]:=frandom(0.005, 0.2);
    FOR n:=1 TO numInput DO
     hiddenW[i, n]:=frandom(-0.1, 0.15);
   END;
  FOR i:=1 TO numOutput DO
   BEGIN
    FOR n:=1 TO numhidden DO
     outputW[i, n]:=frandom(-0.1, 0.15);
   END;
 END;  { init }

the problem is i know nothing about PASCAL and there isint an elaborate example on how to create a two-dimensional array. i am stuck at the line 
hiddenW[i, n]:=frandom(-0.1, 0.15);

here's my version :
function init() {
 for ($i=1; $i<=numhidden; $i++) {
  $hiddenA[$i]=frandom(0.005, 0.2);
  for ($n=1; $n<=numInput; $n++) {
   $hiddenW = array ($i => array ($n => frandom(-0.1, 0.15)));
   print("<pre>");
   print_r($hiddenW);
   print("</pre>");
  } 
 }
 print("<pre>");
 print_r($hiddenA);
 print("</pre>");
 print_r($hiddenW);
 for ($i=1; $i<=$numOutput; $i++) {
  for ($n=1; $n<=numhidden; $n++) {
   //$outputW[$i, $n]=frandom(-0.1, 0.15);
  }
 }
} // { init }
it seems to dump values... i am unsure if its right. 
i need the values elsewhere...
for ($i=1; $i<=numhidden; $i++) {
 $sum2=0;
 for ($j=1; $j<=numInput; $j++) {
  $sum2=$sum2 + $hiddenW[$i, $j] * $inputA[$j]; //at this point i am totally blank
  echo $sum2;
  $hiddenN[$i]=$sum2;
  $hiddenA[$i]=sigmoid($sum2);
 }
}
has someone done this sort of programming before. there sure must be a better way to code this procedure out. plz help
Thz
Tracy


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Coming together is a beginning... 
   keeping together is progress... 
      working together is success !!!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


---------------------------------
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20030324/83b32529/attachment.html>


More information about the talk mailing list