Thanks so much for the quick reply!!
Actually this code works fine on some inputs but fails on others (they are all from the same batch) and that’s why I’m so confused. These are MRI data so unfortunately it may be hard to reproduce the error without those data. I have examined my data and there is no nan in it. What’s more wired is that if “take out” those unnormal data and apply a convolution layer for it, it seems to work fine
e.g.
encoder_1 = nn.Sequential(
nn.Conv3d(1,25,7,padding=6,dilation=2),
nn.BatchNorm3d(25),
nn.PReLU()
)
encoder_1(unnormalData)
I got:
0 ,0 ,25,.,.) =
1.00000e-07 *
0.0000 0.0000 0.0000 … 0.0000 0.0000 0.0000
0.0000 0.0000 0.0000 … 0.0000 0.0000 0.0000
0.0000 0.0000 0.0000 … 0.0000 0.0000 0.0000
… ? …
0.0000 0.0000 0.0000 … 0.0000 0.0000 0.0000
0.0000 0.0000 0.0000 … 0.0000 0.0000 0.0000
0.0000 0.0000 0.0000 … 0.0000 0.0000 0.0000
(0 ,0 ,26,.,.) =
1.00000e-07 *
0.0000 0.0000 0.0000 … 0.0000 0.0000 0.0000
0.0000 0.0000 0.0000 … 0.0000 0.0000 0.0000
0.0000 0.0000 0.0000 … 0.0000 0.0000 0.0000
… ? …
0.0000 0.0000 0.0000 … 0.0000 0.0000 0.0000
0.0000 0.0000 0.0000 … 0.0000 0.0000 0.0000
0.0000 0.0000 0.0000 … 0.0000 0.0000 0.0000
?
(0 ,1 ,0 ,.,.) =
1.00000e-07 *
8.8292 8.8292 8.8292 … 8.8292 8.8292 8.8292
8.8292 8.8292 8.8292 … 8.8292 8.8292 8.8292
8.8292 8.8292 8.8292 … 8.8292 8.8292 8.8292
… ? …
8.8292 8.8292 8.8292 … 8.8292 8.8292 8.8292
8.8292 8.8292 8.8292 … 8.8292 8.8292 8.8292
8.8292 8.8292 8.8292 … 8.8292 8.8292 8.8292
I have separate scripts for the net and training. When I run the train.py, this is what I got after applying the first convolutional layer (the exact setup as the one I gave above):
encoder_1 Variable containing:
(0 ,0 ,0 ,.,.) =
nan nan nan … nan nan nan
nan nan nan … nan nan nan
nan nan nan … nan nan nan
… ? …
nan nan nan … nan nan nan
nan nan nan … nan nan nan
nan nan nan … nan nan nan
(0 ,0 ,1 ,.,.) =
nan nan nan … nan nan nan
nan nan nan … nan nan nan
nan nan nan … nan nan nan
… ? …
nan nan nan … nan nan nan
nan nan nan … nan nan nan
nan nan nan … nan nan nan
(0 ,0 ,2 ,.,.) =
nan nan nan … nan nan nan
nan nan nan … nan nan nan
nan nan nan … nan nan nan
… ? …
nan nan nan … nan nan nan
nan nan nan … nan nan nan
nan nan nan … nan nan nan
...
Traceback (most recent call last):
File “/Users/xxx/Desktop/Net/train.py”, line 85, in
output = net(imgdata)
File “/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/torch/nn/modules/module.py”, line 224, in call
result = self.forward(*input, **kwargs)
File “/Users/xxx/Desktop/YL-Net/YLNet3D.py”, line 101, in forward
de1_unpool = self.unpool_1(de_1, indices_3, output_size=size_3) #transfer of indices
File “/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/torch/nn/modules/module.py”, line 224, in call
result = self.forward(*input, **kwargs)
File “/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/torch/nn/modules/pooling.py”, line 371, in forward
self.padding, output_size)
File “/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/torch/nn/functional.py”, line 352, in max_unpool3d
return _functions.thnn.MaxUnpool3d.apply(input, indices, output_size, stride, padding)
File “/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/torch/nn/_functions/thnn/pooling.py”, line 241, in forward
ctx.padding[0], ctx.padding[2], ctx.padding[1])
RuntimeError: found an invalid max index 16321 (output volumes are of size 6x6x6) at /Users/soumith/code/builder/wheel/pytorch-src/torch/lib/THNN/generic/VolumetricMaxUnpooling.c:118