ThomasDelteil commented on issue #11133: Manipulating nn.Dense(...) layer 
parameters
URL: 
https://github.com/apache/incubator-mxnet/issues/11133#issuecomment-402830144
 
 
   @lu4 
   To expand on @thomelane, here is a practical example of how you can set the 
data:
   
   ```python
   # Create a layer
   net = gluon.nn.Dense(2, in_units=100, use_bias=True)
   net.initialize()
   ​
   # Update the weights of a layer
   net.weight.set_data(mx.nd.ones((2,100)))
   net.bias.set_data(mx.nd.ones((2)))
   
   1,100
   net(mx.nd.ones((1,100)))
   [[101. 101.]]
   <NDArray 1x2 @cpu(0)>
   ```
   
   To expand on his warning, you'd need to initialize the network at the 
maximum size first, because you can't reshape the parameters but you can indeed 
fill them with weights padded with zeros.
   
   @indhub Could you please close the issue? Thanks!
   @lu4 if that doesn't answer your question and you would like to follow up, 
please create a post on https://discuss.mxnet.io Thanks!

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