nudles commented on a change in pull request #475: SINGA-463 fixed python 
test_operation
URL: https://github.com/apache/incubator-singa/pull/475#discussion_r299836848
 
 

 ##########
 File path: python/singa/autograd.py
 ##########
 @@ -924,17 +924,14 @@ def __init__(
         )
         self.W.gaussian(0.0, std)
 
-        if self.bias:
-            b_shape = (self.out_channels,)
-            self.b = Tensor(shape=b_shape, requires_grad=True, 
stores_grad=True)
-            self.b.set_value(0.0)
-        else:
-            # to keep consistency when to do forward.
-            self.b = None
-            # Tensor(data=CTensor([]), requires_grad=False, stores_grad=False)
+        b_shape = (self.out_channels,)
+        # forward method required bias variable to proceed (dummy b tensor)
+        self.b = Tensor(shape=b_shape, requires_grad=self.bias, 
stores_grad=self.bias)
+        self.b.set_value(0.0)
 
 Review comment:
   the bias tensor cannot be created here because onnx will consider it a real 
bias (onnx has no bias_term flag).
   [this 
line](https://github.com/apache/incubator-singa/blob/b99aaa9f87ccbd4cf111e76013b8387b7129bd8b/python/singa/autograd.py#L791)
 should also be updated to set b as an optional argument `forward(self, x, W, 
b=None)`.
   You can create the tensor for b before calling the CPP function.

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


With regards,
Apache Git Services

Reply via email to