You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/05/13 11:36:30 UTC

[GitHub] some-guy1 commented on issue #10890: [R] Is it possible to train Mxnet symbols and a GLM pretrained model as loss?

some-guy1 commented on issue #10890: [R] Is it possible to train Mxnet symbols and a GLM pretrained model as loss?
URL: https://github.com/apache/incubator-mxnet/issues/10890#issuecomment-388620373
 
 
   Ok I want to be able to use any other technique.  GLM, forests, SVR, boosting, etc etc.
   
   After looking through some of the source code I noticed that the values in the custom metric are no longer symbols, but are actual values.  So, I tried to first turn off the loss by:
   
   ```
   last_activation <- mx.symbol.Activation(data= conv_6, act_type = "sigmoid", name="Last_act_8")
   last <- mx.symbol.concat(data=c(last_activation,data), num.args = 2, dim = 1, name='cato_last')
   NN_Model <- mx.symbol.MakeLoss(last )
   ```
   Then I created a custom metric:
   
   ```
   mx.metric.GAN <- mx.metric.custom("GAN", function(label, pred)
   {
      res = 0 
      for(i in 1:batch_size)
      {      
        label.data = tail(pred[,i], 9)
        pred.data = head(pred[,i], -9)     
        dim(pred.data) <- c(238,238,3,1)     
        flat = nn.function(pred.data[,,,1])
        svr.pred = predict(svm.model, t(flat))
        res = res + (svr.pred - label.data[1] )^2       
      }   
      return(as.array(res))
   })
   ```
   
   This seems to actually call the other R functions that I want.  But, now mxnet appears to be attempting to maximize the metric instead of minimize it.
   
   Seems like I am very close to getting this to work, but I am not sure if the way I have manipulated the custom loss function is appropriate. 
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services