MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / test_shape

Method test_shape

tests/networks/nets/test_net_adapter.py:46–54  ·  view source on GitHub ↗
(self, input_param, input_shape, expected_shape)

Source from the content-addressed store, hash-verified

44class TestNetAdapter(unittest.TestCase):
45 @parameterized.expand([TEST_CASE_0, TEST_CASE_1, TEST_CASE_2, TEST_CASE_3, TEST_CASE_4])
46 def test_shape(self, input_param, input_shape, expected_shape):
47 spatial_dims = input_param["dim"]
48 stride = (1, 2, 2)[:spatial_dims]
49 model = resnet18(spatial_dims=spatial_dims, conv1_t_stride=stride)
50 input_param["model"] = model
51 net = NetAdapter(**input_param).to(device)
52 with eval_mode(net):
53 result = net.forward(torch.randn(input_shape).to(device))
54 self.assertEqual(result.shape, expected_shape)
55
56 @parameterized.expand([TEST_CASE_0])
57 def test_script(self, input_param, input_shape, expected_shape):

Callers

nothing calls this directly

Calls 4

resnet18Function · 0.90
NetAdapterClass · 0.90
eval_modeFunction · 0.90
forwardMethod · 0.45

Tested by

no test coverage detected