You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@singa.apache.org by GitBox <gi...@apache.org> on 2020/05/09 10:03:45 UTC

[GitHub] [singa] nudles opened a new issue #693: Extend the Module class

nudles opened a new issue #693:
URL: https://github.com/apache/singa/issues/693


   In  #674 , we propose to move the param creation and initialization into the forward propagation stage, i.e., `__call__`. 
   However, sometimes, we may want to access the parameters of a model after it is created, e.g., 
   ```python
   m = ModelFoo()
   m.get_params()  # returns the params of each layer via get_params
   ```
   We will get errors since the params are not created yet.
   To resolve this issue, we can add a new method to the Module class
   ```python
   def init(self, x):
       # x represents the input tensor(s) whose values could be randomly filled, 
       # but the shape and device are set correctly.
       self.forward(x)  # the forward propagation will initialize all params.
   ```
   The following code will pass without errors.
   ```python
   m = ModelFoo()
   m.init(x)
   m.get_params()  # returns the params of each layer via get_params
   ```
   
   comments?
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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



[GitHub] [singa] nudles commented on issue #693: Extend the Module class

Posted by GitBox <gi...@apache.org>.
nudles commented on issue #693:
URL: https://github.com/apache/singa/issues/693#issuecomment-629601708


   #696 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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



[GitHub] [singa] nudles closed issue #693: Extend the Module class

Posted by GitBox <gi...@apache.org>.
nudles closed issue #693:
URL: https://github.com/apache/singa/issues/693


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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