SINGA-383 Add Separable Convolution for autograd - rename two functions, spacial_conv and depth_conv, in SeparableConv2d Layer.
Project: http://git-wip-us.apache.org/repos/asf/incubator-singa/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-singa/commit/8aac80e4 Tree: http://git-wip-us.apache.org/repos/asf/incubator-singa/tree/8aac80e4 Diff: http://git-wip-us.apache.org/repos/asf/incubator-singa/diff/8aac80e4 Branch: refs/heads/master Commit: 8aac80e425d9a146f8a86b6e38a023edca542099 Parents: d5422a4 Author: xuewanqi <[email protected]> Authored: Fri Aug 24 02:19:18 2018 +0000 Committer: xuewanqi <[email protected]> Committed: Fri Aug 24 02:19:18 2018 +0000 ---------------------------------------------------------------------- python/singa/autograd.py | 8 ++++---- test/python/test_operation.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/8aac80e4/python/singa/autograd.py ---------------------------------------------------------------------- diff --git a/python/singa/autograd.py b/python/singa/autograd.py index 84afcd1..b521126 100755 --- a/python/singa/autograd.py +++ b/python/singa/autograd.py @@ -781,14 +781,14 @@ class SeparableConv2d(Layer): def __init__(self, in_channels, out_channels, kernel_size, stride=1, padding=0, bias=False): - self.mapping_spacial_conv = Conv2d( + self.spacial_conv = Conv2d( in_channels, in_channels, kernel_size, stride, padding, groups=in_channels, bias=bias) - self.mapping_depth_conv = Conv2d(in_channels, out_channels, 1, bias=bias) + self.depth_conv = Conv2d(in_channels, out_channels, 1, bias=bias) def __call__(self, x): - y = self.mapping_spacial_conv(x) - y = self.mapping_depth_conv(y) + y = self.spacial_conv(x) + y = self.depth_conv(y) return y http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/8aac80e4/test/python/test_operation.py ---------------------------------------------------------------------- diff --git a/test/python/test_operation.py b/test/python/test_operation.py index d20e764..2fdd9fb 100755 --- a/test/python/test_operation.py +++ b/test/python/test_operation.py @@ -106,8 +106,8 @@ class TestPythonOperation(unittest.TestCase): x=tensor.Tensor(device=gpu_dev, data=x) #y = separ_conv(x) - y1 = separ_conv.mapping_spacial_conv(x) - y2 = separ_conv.mapping_depth_conv(y1) + y1 = separ_conv.spacial_conv(x) + y2 = separ_conv.depth_conv(y1) dy1, dW_depth, _ = y2.creator.backward(y2.data) dx, dW_spacial, _ = y1.creator.backward(dy1)
