MCPcopy Create free account
hub / github.com/pytorch/pytorch / test_relu

Method test_relu

caffe2/python/brew_test.py:55–71  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

53 workspace.RunNetOnce(model.net)
54
55 def test_relu(self):
56 Xpos = np.ones((5, 5)).astype(np.float32) - 0.5
57 Xneg = np.ones((5, 5)).astype(np.float32) - 1.5
58
59 workspace.FeedBlob("xpos", Xpos)
60 workspace.FeedBlob("xneg", Xneg)
61 model = ModelHelper(name="test_model")
62 brew.relu(model, "xpos", "out_xpos")
63 brew.relu(model, "xneg", "out_xneg")
64 model.Validate()
65 workspace.RunNetOnce(model.param_init_net)
66 workspace.RunNetOnce(model.net)
67
68 pos = workspace.FetchBlob("out_xpos")
69 self.assertAlmostEqual(pos.mean(), 0.5)
70 neg = workspace.FetchBlob("out_xneg")
71 self.assertAlmostEqual(neg.mean(), 0)
72
73 def test_tanh(self):
74 X = np.ones((5, 5)).astype(np.float32) - 0.5

Callers

nothing calls this directly

Calls 6

ValidateMethod · 0.95
ModelHelperClass · 0.90
astypeMethod · 0.80
onesMethod · 0.45
reluMethod · 0.45
meanMethod · 0.45

Tested by

no test coverage detected