apache / mxnet

Lightweight, Portable, Flexible Distributed/Mobile Deep Learning with Dynamic, Mutation-aware Dataflow Dep Scheduler; for Python, R, Julia, Scala, Go, Javascript and more
https://mxnet.apache.org
Apache License 2.0
20.78k stars 6.79k forks source link

multiple loss in R #3437

Open ivokwee opened 8 years ago

ivokwee commented 8 years ago

Hi. I am trying to get multiple loss function using R in this code

data <- mx.symbol.Variable('data') fc1 <- mx.symbol.FullyConnected(data = data, name = 'fc1', num_hidden = 64) act1 <- mx.symbol.Activation(data = fc1, name = 'relu1', act_type = "relu") fc2 <- mx.symbol.FullyConnected(data = act1, name = 'fc2', num_hidden = 10)

label1 <- mx.symbol.Variable('out1_label') label2 <- mx.symbol.Variable('out2_label') out1 <- mx.symbol.SoftmaxOutput(data = fc2, name='out1', label=label1) out2 <- mx.symbol.SoftmaxOutput(data = fc2, name='out2', label=label2) mlp <- mx.symbol.Group(out1, out2)

Y <- list( out1_label=train.y, out2_label=train.y )

model <- mx.model.FeedForward.create( symbol = mlp, X = t(train.x), y = Y, eval.metric = mx.metric.rmse, array.layout = "colmajor" )

But it get this error:

Error in eval(substitute(expr), envir, enclos) : not compatible with requested type

Is multiple loss supported in the R interface? What might I be doing wrong?

Thanks,

Ivo

winstywang commented 8 years ago

@thirdwing

thirdwing commented 8 years ago

I think this has not been supported in R side.

Leloew commented 7 years ago

Hey, any alternative to this? I am trying to implement an autoencoder and would like to have softmax loss for the categorical variablels and MAE for the numericall one.

thirdwing commented 7 years ago

@Leloew Can I know why you can't build two symbols according to different types of results?

Leloew commented 7 years ago

Hey @thirdwing, thanks for the reply. I want to have a shared hidden representation for both the categorical and the numerical variables. Is it possible to implement this with two seperate symbols? or what do you mean exactly? Do you mean Symbol.group?

Edit ah do you mean the multiple loss is implemented, just not inserting two Labels? ( then it wouldnt be a Problem for the Autoencoder since the Labels are the data. )