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

Method test_model_helper

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

Source from the content-addressed store, hash-verified

162 self.assertFalse(brew.has_helper(myhelper3))
163
164 def test_model_helper(self):
165 X = np.random.rand(64, 32, 32, 3).astype(np.float32) - 0.5
166
167 workspace.FeedBlob("x", X)
168 my_arg_scope = {'order': 'NHWC'}
169 model = ModelHelper(name="test_model", arg_scope=my_arg_scope)
170 with brew.arg_scope(
171 brew.conv,
172 stride=2,
173 pad=2,
174 weight_init=('XavierFill', {}),
175 bias_init=('ConstantFill', {})
176 ):
177 brew.conv(
178 model=model,
179 blob_in="x",
180 blob_out="out",
181 dim_in=3,
182 dim_out=64,
183 kernel=[8, 3]
184 )
185 model.Validate()
186 workspace.RunNetOnce(model.param_init_net)
187 workspace.RunNetOnce(model.net)
188 out = workspace.FetchBlob("out")
189 self.assertEqual(out.shape, (64, 15, 17, 64))
190
191 def test_cnn_model_helper_deprecated(self):
192 X = np.random.rand(64, 32, 32, 3).astype(np.float32) - 0.5

Callers

nothing calls this directly

Calls 7

ValidateMethod · 0.95
ModelHelperClass · 0.90
astypeMethod · 0.80
arg_scopeMethod · 0.80
randMethod · 0.45
convMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected