Hello Alan;

I can see some misunderstandings of J that might not get fixed in a single email. I have only a 50% confidence that I can even see what you are trying to do. I'll ask some questions, phrased so that each question is answerable with Yes:

0. Is it true that you see the following sentence as your 'main' sentence:

   NetParams calcNetError Weights

1. do you see that the following sentence does the same thing?

  (NIn; NHid; Nout; Data) calcNetError Weights

2. Do you see that your sentence:

calcNetError=: Input,desOutputs, Output, Error

defines 'calcNetError' as a noun?

3. Are you thinking that J works like FORTRAN, in that when you assign an expression to a function name, you are setting the return value of the function?

3a. Do you know that the return value of an explicitly defined J verb is the value of last expression executed?

4. Do you see that, the way you have defined Data,  it is the same as >Data

5. Do you see that 2{|:>Data is the same as 2({"1)Data? This gives you the 2 column without having to do a transpose?

6. Does something like this work:

calcNetError=: 3 : 0
'NIn NHid Nout Data' =. x NB. The left argument is x; Do you understand what is going on here with 'name name' =. expression?
   Weights =. y NB. The right argument is y
   Input =. 0 1 {"1 Data
   desOutputs =. 2{"1 Data
Output =. Input propagate Weights NB. There may be some problems here, as 'propogate' uses global names. That may need to wait for another message.
   Error =. +/ *: Output-desOutputs
Input;desOutputs;Output;Error NB. last expression, therefore the return value. I changed the , to a ;
)

(NIn; NHid; Nout; Data)  calcNetError Weights

(there will be those who complain that I'm doing someones homework I say 7 lines of J won't spoil him.)

7. Does this get you started?

Alan Mac Hugh wrote:
Hi I'm working on a assignment for college, I would e-mail my lecture, but the assignment due in on Monday at 12noon and I'm not sure if he checks his e-mail over the weekend. I have got the program working, but the output is
not right.

When I type in

NetParams calcNetError Weights

I should just get the answer.

I know the answer there as when I type calcNetError, the answer is the last thing displayed.The propagate function is my lectures solution to a previous
assignment all the rest is my own code.

Below is the code:

[code]

nProd =:  +/ . *     NB. dyad: returns inner product of x and y

sig =:  [: %@:>: [: ^@:- ]   NB. monad: returns sigmoid function of y

getIHW =:   (2 2) $ (i. 4) { ]    NB. monad: returns the input->hidden
weight matrix from y

getHOW =: (2 1) $ (4 + i. 2) { ] NB. monad: returns the hidden->output
weight matrix from y

calcHiddenOut =:[: sig [ inProd getIHW NB. dyad: returns the hidden unit
activations

     NB. from input x to network with y weights

propagate =:  [: sig calcHiddenOut inProd getHOW NB. dyad: returns the
output from the output unit

     NB. from input x to a network with y weights





] Weights =: 10 5 15 30 1 1

10 5 15 30 1 1



 NIn=: 2

 NHid=:2

 Nout=:1

 Data=:0 1 1, 1 0 1, 0 0 0,: 1 1 0



NetParams=:NIn; NHid; Nout; Data

Input=: |: (0 1 { |: > Data)

desOutputs=:|: ( 2 { |: > Data)

Output=:Input  propagate Weights

Error=:+/ *: Output-desOutputs

calcNetError=: Input,desOutputs, Output, Error

NetParams calcNetError Weights


[/code]
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to