Code Monkey home page Code Monkey logo

Comments (3)

akzaidi avatar akzaidi commented on May 19, 2024

@slaweks17 very sorry for the late reply!
Could you try again with the latest? There was a typo in the op_reduce_sum.

from cntk-r.

akzaidi avatar akzaidi commented on May 19, 2024

@slaweks17 you can define the smape similarly to how you would in python:

smape_loss <- function(z, t) {
  
  loss <- op_reduce_mean(op_abs(t - z)/(t + z))
  loss
  
}

linear_layer <- function(input_var, output_dim) {
  
  input_var <- nrow(input_var)
  times_p <- op_parameter(shape = c(input_dim, output_dim))
  bias_p <- op_parameter(shape = output_dim)
  t <- op_times(input_var, times_p)
  
  bias_p + t
  
}

r <- Recurrence(LSTM(hidden_layer_dim1,
                     use_peepholes = LSTM_PEEP,
                     enable_self_stabilization = STABILIZE))(input_var)

z <- linear_layer(r, output_dim)
loss <- smape_loss(z, label)

from cntk-r.

slaweks17 avatar slaweks17 commented on May 19, 2024

Hi,
I followed you advice, although I had to use op_minus and op_plus instead of - and + respectively, and there was no error when calling this function below.
sMAPELoss<-function (z, output_var){
loss <- op_reduce_mean(op_element_divide(op_abs(op_minus(z,output_var)),op_plus(output_var,z)))
loss
}
But strangely, if I change op_reduce_mean() to op_reduce_sum(), I am getting the same
AttributeError: 'Variable' object has no attribute 'is_static_axis'

Anyway, thank you, I can live with mean, even if sum is a bit better. I have not tested this comprehensively, as I do not work with NNs at the moment, but I will within next few weeks.
I guess the issue can be closed in the meantime.

Regards,
Slawek

from cntk-r.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.