yifeishi/PlaneMatch

AttributeError: 'BatchNorm2d' object has no attribute 'num_batches_tracked'

Opened this issue · 2 comments

I'm using pytorch0.3.1 with python3.6, cudnn-7.1.3 and cudatoolkit-8.0 and had some problems. I have googled and know that it is because the pytorch version I used is different from that is used to train the model.

The log is below:
Start testing ......
Traceback (most recent call last):
File "/mnt/E/zhenglongyu/pycharm-community-2018.1.4/helpers/pydev/pydev_run_in_console.py", line 52, in run_file
pydev_imports.execfile(file, globals, locals) # execute the script
File "/mnt/E/zhenglongyu/pycharm-community-2018.1.4/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/mnt/E/zhenglongyu/PlaneMatch/test.py", line 77, in
feature1 = model(x1, x4, x7, x10, x13, x16, x19, x22)
File "/mnt/E/zhenglongyu/pytorch_conda/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/mnt/E/zhenglongyu/PlaneMatch/network_planematch.py", line 172, in forward
x1 = self.bn1(x1)
File "/mnt/E/zhenglongyu/pytorch_conda/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/mnt/E/zhenglongyu/pytorch_conda/lib/python3.6/site-packages/torch/nn/modules/batchnorm.py", line 57, in forward
self.num_batches_tracked += 1
File "/mnt/E/zhenglongyu/pytorch_conda/lib/python3.6/site-packages/torch/nn/modules/module.py", line 518, in getattr
type(self).name, name))
AttributeError: 'BatchNorm2d' object has no attribute 'num_batches_tracked'
PyDev console: starting.
Python 3.6.6 |Anaconda, Inc.| (default, Oct 9 2018, 12:34:16)
[GCC 7.3.0] on linux
QXcbConnection: Failed to initialize XRandr
Qt: XKEYBOARD extension not present on the X server.

So could you tell me the pytorch version you used to train the model

Did you solve the problem? I would recommend you to first switch to python 2.7 and see if that works.

I got the same error but not in training the model.. just testing it.

I realized I forgot to add:

model.eval()