Uploaded image for project: 'SystemDS'
  1. SystemDS
  2. SYSTEMDS-1759

make UDFs callable from expressions

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Duplicate
    • SystemML 1.0.0
    • SystemML 1.1
    • Parser
    • None
    • IBM DataScience Experience

    Description

      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

      Attachments

        Issue Links

          Activity

            People

              mboehm7 Matthias Boehm
              romeokienzler Romeo Kienzer
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: