singa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [incubator-singa] dcslin commented on a change in pull request #475: SINGA-463 fixed separable conv2d
Date Wed, 03 Jul 2019 07:16:23 GMT
dcslin commented on a change in pull request #475: SINGA-463 fixed separable conv2d 
URL: https://github.com/apache/incubator-singa/pull/475#discussion_r299807257
 
 

 ##########
 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:
   Hi, yes. This change is to cater the backend cpp API, which requires bias to be passed
in.
   for example: `src/model/operation/convolution.h`
   ```c++
   Tensor GpuConvForward(const Tensor &x, const Tensor &W, const Tensor &b, const
CudnnConvHandle &cch);
   ``` 
   In the frontend, python side, it will not be updated:
   `python/singa/autograd.py`
   ```python
   if self.handle.bias_term:
       # compute db
   ```

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


With regards,
Apache Git Services

Mime
View raw message