[ 
https://issues.apache.org/jira/browse/SYSTEMML-1759?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16083412#comment-16083412
 ] 

Matthias Boehm commented on SYSTEMML-1759:
------------------------------------------

yes, this should definitely be addressed; the same issues has been raised here: 
https://www.mail-archive.com/dev@systemml.apache.org/msg00095.html

> make UDFs callable from expressions
> -----------------------------------
>
>                 Key: SYSTEMML-1759
>                 URL: https://issues.apache.org/jira/browse/SYSTEMML-1759
>             Project: SystemML
>          Issue Type: Improvement
>          Components: Parser
>    Affects Versions: SystemML 1.0
>         Environment: IBM DataScience Experience
>            Reporter: Romeo Kienzer
>            Priority: Minor
>
> SystemML Parser stops with exeption:
> only builtin functions allowed as part of
> expression
> But the following re-write could be automated during parsing
> delta3 = -(Y-yHat) * sigmoidPrime(z3)
> =>
> smp = sigmoidPrime(z3)
> delta3 = -(Y-yHat) * smp
> Please consider the following code:
>     script = """
>     
>     #
>     sigmoid = function(matrix[double] z) return (matrix[double] z) {
>         z = 1/(1+exp(-z))
>     }
>     
>     
>     sigmoidPrime = function(matrix[double] z) return (matrix[double] z) {
>             #Gradient of sigmoid
>             z = exp(-z)/(1+exp(-z))
>     }
>     
>     X=matrix("3 5 5 1 10 2", rows=3, cols=2) 
>     inputLayerSize = 2
>     outputLayerSize = 1
>     hiddenLayerSize = 3
>     
>     W1 = rand(rows=inputLayerSize,cols=hiddenLayerSize)
>     W2 = rand(rows=hiddenLayerSize,cols=outputLayerSize)
>     
>     feedForward = function (matrix[double] X,
>                             matrix[double] W1,
>                             matrix[double] W2) return (matrix[double] 
> z2,matrix[double] z3,matrix[double] Y) {
>         z2 =  X %*% W1
>         a2 =  sigmoid(z2)
>         z3 = (a2 %*% W2)
>         Y = sigmoid(z3)
>     }
>     
>     
>     gradient = function(matrix[double] X,
>                             matrix[double] W1,
>                             matrix[double] W2,
>                             matrix[double] Y) return (matrix[double] 
> dJdW1,matrix[double] dJdW1) {
>         #Compute derivative with respect to W and W2 for a given X and y:
>         [z2,z3,Yhat] = feedForward(X,W1,W2)
>            
>         delta3 = -(Y-yHat) * sigmoidPrime(z3)
>         dJdW2 = t(a2) %*% delta3
>             
>         delta2 = (delta3 %*% t(W2))*sigmoidPrime(z2)
>         dJdW1 = t(X) %*% delta2  
>     }
>     
>     [z2,z3,Yhat]=feedForward(X,W1,W2)
>     nrx = nrow(X)
>     ncx = ncol(X)
>     nrw1 = nrow(W1)
>     ncw1 = ncol(W1)
>     """
> I'm getting a parser exeption saying that
> Caused by: org.apache.sysml.parser.ParseException: 
> -------------------------------------------------------------- The following 
> 2 parse issues were encountered:
> 1 [line 39:25] [Validation error] ->     delta3 = -(Y-yHat) * 
> sigmoidPrime(z3)    only builtin functions allowed as part of
> expression
> 2 [line 42:32] [Validation error] ->     delta2 = (delta3 %*% > 
> t(W2))*sigmoidPrime(z2)    only builtin functions allowed as part of
> expression



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to