MCPcopy Create free account
hub / github.com/apache/singa / _conv2d_helper

Method _conv2d_helper

test/python/test_operation.py:119–140  ·  view source on GitHub ↗
(self, dev)

Source from the content-addressed store, hash-verified

117 self._greater_helper(gpu_dev)
118
119 def _conv2d_helper(self, dev):
120 # (out_channels, kernel_size)
121 conv_0 = layer.Conv2d(1, 2)
122 conv_without_bias_0 = layer.Conv2d(1, 2, bias=False)
123
124 cpu_input_tensor = tensor.Tensor(shape=(2, 3, 3, 3), device=dev)
125 cpu_input_tensor.gaussian(0.0, 1.0)
126
127 dy = tensor.Tensor(shape=(2, 1, 2, 2), device=dev)
128 dy.gaussian(0.0, 1.0)
129
130 y = conv_0(cpu_input_tensor) # PyTensor
131 dx, dW, db = y.creator.backward(dy.data) # CTensor
132
133 self.check_shape(y.shape, (2, 1, 2, 2))
134 self.check_shape(dx.shape(), (2, 3, 3, 3))
135 self.check_shape(dW.shape(), (1, 3, 2, 2))
136 self.check_shape(db.shape(), (1,))
137
138 # forward without bias
139 y_without_bias = conv_without_bias_0(cpu_input_tensor)
140 self.check_shape(y_without_bias.shape, (2, 1, 2, 2))
141
142 def test_conv2d_cpu(self):
143 self._conv2d_helper(cpu_dev)

Callers 2

test_conv2d_cpuMethod · 0.95
test_conv2d_gpuMethod · 0.95

Calls 5

gaussianMethod · 0.95
check_shapeMethod · 0.95
TensorMethod · 0.80
shapeMethod · 0.80
backwardMethod · 0.45

Tested by

no test coverage detected