Ishitori commented on issue #13731: Contrib Symbol API of MXNet in R?
URL: 
https://github.com/apache/incubator-mxnet/issues/13731#issuecomment-450216929
 
 
   At this moment your best bet would be to use 
[reticulate](https://blog.rstudio.com/2018/03/26/reticulate-r-interface-to-python/)
 package to use python version of MXNet.
   
   I haven't tried mxnet.symbol.contrib, but my test autograd example seems to 
work fine:
   
   ```
   library(reticulate)
   mxnet_python <- import("mxnet")
   x <- mxnet_python$nd$array(c(1, 2, 3, 4))
   
   x$attach_grad()
   
   mxnet_python$autograd$set_recording(T)
   y <- mxnet_python$nd$sqrt(x)
   mxnet_python$autograd$set_recording(F)
   
   y$backward()
   print(x$grad)
   ```
   
   ```
   [0.5        0.35355338 0.28867513 0.25      ]
   <NDArray 4 @cpu(0)>
   ```
   The syntax doesn't look as nice as original R client, but it works.
   
   So, just `pip install mxnet`, then in R `install.packages('reticulate')` and 
then use functions from Python replacing `.` with `$`.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to