Translate.py error: 'NoneType' object has no attribute 'transpose'

Hello, everyone. I tried the PyTorch version of OpenNMT today. I followed the instructions from official guide and tried to run the demo. Everything is OK until I tried to translate the testing file by using a trained model. I run following code in the bash:

python2 translate.py -model model_e13_1024.75.pt -src data/src-test.txt -output baseline.tgt.txt -gpu 0

and got the follow error:

Traceback (most recent call last):
File “translate.py”, line 116, in
main()
File “translate.py”, line 77, in main
predBatch, predScore, goldScore = translator.translate(srcBatch, tgtBatch)
File “/home/v-hanql/OpenNMT-py/onmt/Translator.py”, line 192, in translate
batch = [x.transpose(0, 1) for x in batch]
AttributeError: ‘NoneType’ object has no attribute ‘transpose’

I was very confused by this error. When I use the Lua version, everything is OK. Could somebody please tell me why?

The Python version still has some small issues like this one. A new version is coming soon:

As for this particular error, I remember it happening when you don’t provide gold data during translation (-tgt option).