(self, order)
| 107 | return model |
| 108 | |
| 109 | def _testMiniAlexNet(self, order): |
| 110 | # First, we get all the random initialization of parameters. |
| 111 | model = self._MiniAlexNetNoDropout(order) |
| 112 | workspace.ResetWorkspace() |
| 113 | workspace.RunNetOnce(model.param_init_net) |
| 114 | inputs = dict( |
| 115 | [(str(name), workspace.FetchBlob(str(name))) for name in |
| 116 | model.params] |
| 117 | ) |
| 118 | if order == "NCHW": |
| 119 | inputs["data"] = np.random.rand(4, 3, 227, 227).astype(np.float32) |
| 120 | else: |
| 121 | inputs["data"] = np.random.rand(4, 227, 227, 3).astype(np.float32) |
| 122 | inputs["label"] = np.array([1, 2, 3, 4]).astype(np.int32) |
| 123 | |
| 124 | cpu_device = caffe2_pb2.DeviceOption() |
| 125 | cpu_device.device_type = caffe2_pb2.CPU |
| 126 | gpu_device = caffe2_pb2.DeviceOption() |
| 127 | gpu_device.device_type = workspace.GpuDeviceType |
| 128 | |
| 129 | checker = device_checker.DeviceChecker(0.05, [cpu_device, gpu_device]) |
| 130 | ret = checker.CheckNet( |
| 131 | model.net.Proto(), |
| 132 | inputs, |
| 133 | # The indices sometimes may be sensitive to small numerical |
| 134 | # differences in the input, so we ignore checking them. |
| 135 | ignore=['_pool1_idx', '_pool2_idx', '_pool5_idx'] |
| 136 | ) |
| 137 | self.assertEqual(ret, True) |
| 138 | |
| 139 | @unittest.skipIf(not workspace.has_gpu_support, |
| 140 | "No GPU support. Skipping test.") |
no test coverage detected