MCPcopy Index your code
hub / github.com/pytorch/pytorch / test_fully_connected_axis

Method test_fully_connected_axis

caffe2/python/hypothesis_test.py:318–348  ·  view source on GitHub ↗
(self, axis, num_output, engine, gc, dc)

Source from the content-addressed store, hash-verified

316 **hu.gcs)
317 @settings(deadline=10000)
318 def test_fully_connected_axis(self, axis, num_output, engine, gc, dc):
319 np.random.seed(1)
320 X = np.random.randn(1, 2, 3, 2, 1).astype(np.float32)
321
322 def prod(xs):
323 p = 1
324 for x in xs:
325 p *= x
326 return p
327
328 K = prod(list(X.shape)[axis:])
329 N = num_output
330 W = np.random.randn(N, K).astype(np.float32)
331 b = np.random.randn(N).astype(np.float32)
332
333 op = core.CreateOperator(
334 "FC",
335 ["X", "W", "b"],
336 ["Y"],
337 engine=engine,
338 axis=axis)
339 for name, param in [("X", X), ("W", W), ("b", b)]:
340 self.ws.create_blob(name).feed(param)
341 self.ws.run(op)
342 Y = self.ws.blobs["Y"].fetch()
343 self.assertEqual(list(Y.shape), list(X.shape)[:axis] + [N])
344
345 inputs = [X, W, b]
346 self.assertDeviceChecks(dc, op, inputs, [0])
347 for param, _ in enumerate(inputs):
348 self.assertGradientChecks(gc, op, inputs, param, [0])
349
350 @unittest.skipIf(not workspace.has_gpu_support,
351 "Skipping test due to no gpu present.")

Callers

nothing calls this directly

Calls 10

listFunction · 0.85
astypeMethod · 0.80
assertDeviceChecksMethod · 0.80
assertGradientChecksMethod · 0.80
prodFunction · 0.50
seedMethod · 0.45
randnMethod · 0.45
runMethod · 0.45
fetchMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected