Thanks for the response. I checked the implementation and the error seems to originate from an Instancenorm layer. The layer is set to False
after calling model.eval()
. Please suggest what I can do further. Another error I’ve noticed is that the dice coefficient that I use as my metric gives a value of more than 1 on the last few epochs. What could I be doing differently? Here’s the full error
ipython-input-19-4be8d4a14b5d> in <module>
36
37 with torch.no_grad():
---> 38 outputs = model(window)
39
40 outputs = outputs.cpu().numpy()
/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs)
720 result = self._slow_forward(*input, **kwargs)
721 else:
--> 722 result = self.forward(*input, **kwargs)
723 for hook in itertools.chain(
724 _global_forward_hooks.values(),
/workspace/sharad/Final/mod3DUnet.py in forward(self, x)
204 out = self.conv3d_c5(out)
205 residual_5 = out
--> 206 out = self.norm_lrelu_conv_c5(out)
207 out = self.dropout3d(out)
208 out = self.norm_lrelu_conv_c5(out)
/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs)
720 result = self._slow_forward(*input, **kwargs)
721 else:
--> 722 result = self.forward(*input, **kwargs)
723 for hook in itertools.chain(
724 _global_forward_hooks.values(),
/usr/local/lib/python3.6/dist-packages/torch/nn/modules/container.py in forward(self, input)
115 def forward(self, input):
116 for module in self:
--> 117 input = module(input)
118 return input
119
/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs)
720 result = self._slow_forward(*input, **kwargs)
721 else:
--> 722 result = self.forward(*input, **kwargs)
723 for hook in itertools.chain(
724 _global_forward_hooks.values(),
/usr/local/lib/python3.6/dist-packages/torch/nn/modules/instancenorm.py in forward(self, input)
55 return F.instance_norm(
56 input, self.running_mean, self.running_var, self.weight, self.bias,
---> 57 self.training or not self.track_running_stats, self.momentum, self.eps)
58
59
/usr/local/lib/python3.6/dist-packages/torch/nn/functional.py in instance_norm(input, running_mean, running_var, weight, bias, use_input_stats, momentum, eps)
2033 running_var=running_var, weight=weight, bias=bias,
2034 use_input_stats=use_input_stats, momentum=momentum, eps=eps)
-> 2035 _verify_batch_size(input.size())
2036 return torch.instance_norm(
2037 input, weight, bias, running_mean, running_var,
/usr/local/lib/python3.6/dist-packages/torch/nn/functional.py in _verify_batch_size(size)
1993 size_prods *= size[i + 2]
1994 if size_prods == 1:
-> 1995 raise ValueError('Expected more than 1 value per channel when training, got input size {}'.format(size))
1996
1997
ValueError: Expected more than 1 value per channel when training, got input size torch.Size([1, 128, 1, 1, 1])