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

Method _dropout_helper

test/python/test_onnx.py:1644–1662  ·  view source on GitHub ↗
(self, dev)

Source from the content-addressed store, hash-verified

1642 self._constantOfShape_helper(gpu_dev)
1643
1644 def _dropout_helper(self, dev):
1645 X = np.random.randn(3, 4, 5).astype(np.float32)
1646
1647 x = tensor.from_numpy(X)
1648 x.to_device(dev)
1649 y = autograd.dropout(x, 0.5)
1650
1651 # frontend
1652 model = sonnx.to_onnx([x], [y])
1653 # print('The model is:\n{}'.format(model))
1654
1655 # backend
1656 sg_ir = sonnx.prepare(model, device=dev)
1657 sg_ir.is_graph = True
1658 y_t = sg_ir.run([x])
1659
1660 self.check_shape(
1661 tensor.to_numpy(y).shape,
1662 tensor.to_numpy(y_t[0]).shape)
1663
1664 def test_dropout_cpu(self):
1665 self._dropout_helper(cpu_dev)

Callers 2

test_dropout_cpuMethod · 0.95
test_dropout_gpuMethod · 0.95

Calls 4

check_shapeMethod · 0.95
prepareMethod · 0.80
to_deviceMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected