def test_ill_arg(self): with self.assertRaises(ValueError): ChannelSELayer(spatial_dims=1, in_channels=4, r=100)
def test_shape(self, input_param, input_data, expected_shape): net = ChannelSELayer(**input_param) net.eval() with torch.no_grad(): result = net(input_data) self.assertEqual(result.shape, expected_shape)
def test_shape(self, input_param, input_shape, expected_shape): net = ChannelSELayer(**input_param) with eval_mode(net): result = net(torch.randn(input_shape)) self.assertEqual(result.shape, expected_shape)
def test_script(self): input_param, input_shape, _ = TEST_CASES[0] net = ChannelSELayer(**input_param) test_data = torch.randn(input_shape) test_script_save(net, test_data)
def test_script(self): input_param, input_shape, _ = TEST_CASES[0] net = ChannelSELayer(**input_param) test_data = torch.randn(input_shape) out_orig, out_reloaded = test_script_save(net, test_data) assert torch.allclose(out_orig, out_reloaded)