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

Method dropout_test

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

Source from the content-addressed store, hash-verified

2723 self.constantOfShape_test(gpu_dev)
2724
2725 def dropout_test(self, dev):
2726 X = np.random.randn(3, 4, 5).astype(np.float32)
2727 dy = np.random.randn(3, 4, 5).astype(np.float32)
2728
2729 x = tensor.from_numpy(X)
2730 dy = tensor.from_numpy(dy)
2731 x.to_device(dev)
2732 dy.to_device(dev)
2733
2734 result = autograd.dropout(x, 0.5)
2735 dx = result.creator.backward(dy.data)
2736 self.check_shape(result.shape, (3, 4, 5))
2737 self.check_shape(dx.shape(), (3, 4, 5))
2738
2739 def test_dropout_cpu(self):
2740 self.dropout_test(cpu_dev)

Callers 2

test_dropout_cpuMethod · 0.95
test_dropout_gpuMethod · 0.95

Calls 4

check_shapeMethod · 0.95
shapeMethod · 0.80
to_deviceMethod · 0.45
backwardMethod · 0.45

Tested by

no test coverage detected