singa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <>
Subject [GitHub] [singa] XJDKC edited a comment on pull request #697: New Model Layer Operator API
Date Sun, 24 May 2020 12:22:48 GMT

XJDKC edited a comment on pull request #697:

   Sorry, the example above is just to show how to create a layer, so I don't consider using
the latest APIs. And there are no direct params in Model. If we let users override set_params/get_params´╝îthe
code for every layer is quite similar.
       def get_params(self):
             self.param_names = ['W', 'b']
             super(LayerName, self).get_params()
       def set_params(self, **params):
             self.param_names = ['W', 'b']
             super(LayerName, self).set_params()
   So if users declare the names of params and states in \_\_init\_\_, we can handle them
well and users just need to override three functions(\_\_init\_\_, initialize, forward). Another
strategy is that we create a subclass of Tensor(named Param) and use that class to create
params. In this way, we can distinguish params from all member variables.
        # self.W = Tensor(shape=w_shape, requires_grad=True, stores_grad=True)
        self.W = Param(shape=w_shape, requires_grad=True, stores_grad=True)

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:

View raw message