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/06/12 00:41:56 UTC

[GitHub] jeremiedb commented on issue #10928: Optimizers memory usage

jeremiedb commented on issue #10928: Optimizers memory usage
URL: https://github.com/apache/incubator-mxnet/issues/10928#issuecomment-396429822
 
 
   As an additional pointer, the issue seems tied to R's NDArray being set to read only after an initial mutation. https://github.com/apache/incubator-mxnet/blob/master/R-package/src/ndarray.h#L86 @tqchen ? 
   
   Basic comparative example between R and Python: 
   
   R: 
   ```
   > state <- mx.nd.array(c(1,2,3,3))
   > grad <- mx.nd.array(1:4)
   > weight <- mx.nd.array(1:4)
   > mx.nd.sgd.mom.update(weight, grad, state, lr = 0.1, momentum = 0.5, out = weight)
   [1] 1.4 2.8 4.2 5.1
   > mx.nd.sgd.mom.update(weight, grad, state, lr = 0.1, momentum = 0.5, out = weight)
   Error in mx.nd.sgd.mom.update(weight, grad, state, lr = 0.1, momentum = 0.5,  : 
     ./ndarray.h:87: RCheck failed: ptr_->writable && !ptr_->moved Passing a read only NDArray to mutate function
   
   ```
   
   Python:
   
   ```
   state  = mx.nd.array([1, 2, 3, 3])
   grad  = mx.nd.array([1,2,3,4])
   weight = mx.nd.array([1,2,3,4])
   print(nd.sgd_mom_update(weight, grad, state, momentum = 0.5, lr=0.1, out=weight))
   print(nd.sgd_mom_update(weight, grad, state, momentum = 0.5, lr=0.1, out=weight))
   
   [1.4 2.8 4.2 5.1]
   <NDArray 4 @cpu(0)>
   
   [1.5  3.   4.5  5.25]
   <NDArray 4 @cpu(0)>
   ```

----------------------------------------------------------------
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