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