(self, axis, num_output, engine, gc, dc)
| 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.") |
nothing calls this directly
no test coverage detected