OpenNMT Forum

RuntimeError: Given groups=1, weight of size [64, 1, 3, 3], expected input[30, 3, 160, 600] to have 1 channels, but got 3 channels instead

I am trying to run OpenNMT-py v1.0.0 im2text markup using the 100K dataset provided – https://github.com/OpenNMT/OpenNMT-py/blob/legacy/docs/source/im2text.md

I have trained the model and using the last/latest generated checkpoint ‘demo-model_step_100000.pt’ for the testing purpose, but I am getting the following error:

Traceback (most recent call last):
File “/opt/automates_venv/bin/onmt_translate”, line 33, in
sys.exit(load_entry_point(‘OpenNMT-py==1.2.0’, ‘console_scripts’, ‘onmt_translate’)())
File “/opt/automates_venv/lib/python3.8/site-packages/OpenNMT_py-1.2.0-py3.8.egg/onmt/bin/translate.py”, line 48, in main
translate(opt)
File “/opt/automates_venv/lib/python3.8/site-packages/OpenNMT_py-1.2.0-py3.8.egg/onmt/bin/translate.py”, line 25, in translate
translator.translate(
File “/opt/automates_venv/lib/python3.8/site-packages/OpenNMT_py-1.2.0-py3.8.egg/onmt/translate/translator.py”, line 361, in translate
batch_data = self.translate_batch(
File “/opt/automates_venv/lib/python3.8/site-packages/OpenNMT_py-1.2.0-py3.8.egg/onmt/translate/translator.py”, line 550, in translate_batch
return self._translate_batch_with_strategy(batch, src_vocabs,
File “/opt/automates_venv/lib/python3.8/site-packages/OpenNMT_py-1.2.0-py3.8.egg/onmt/translate/translator.py”, line 648, in _translate_batch_with_strategy
src, enc_states, memory_bank, src_lengths = self._run_encoder(batch)
File “/opt/automates_venv/lib/python3.8/site-packages/OpenNMT_py-1.2.0-py3.8.egg/onmt/translate/translator.py”, line 557, in _run_encoder
enc_states, memory_bank, src_lengths = self.model.encoder(
File “/opt/automates_venv/lib/python3.8/site-packages/torch-1.8.1-py3.8-linux-x86_64.egg/torch/nn/modules/module.py”, line 889, in _call_impl
result = self.forward(*input, **kwargs)
File “/opt/automates_venv/lib/python3.8/site-packages/OpenNMT_py-1.2.0-py3.8.egg/onmt/encoders/image_encoder.py”, line 79, in forward
src = F.relu(self.layer1(src[:, :, :, :] - 0.5), True)
File “/opt/automates_venv/lib/python3.8/site-packages/torch-1.8.1-py3.8-linux-x86_64.egg/torch/nn/modules/module.py”, line 889, in _call_impl
result = self.forward(*input, **kwargs)
File “/opt/automates_venv/lib/python3.8/site-packages/torch-1.8.1-py3.8-linux-x86_64.egg/torch/nn/modules/conv.py”, line 399, in forward
return self._conv_forward(input, self.weight, self.bias)
File “/opt/automates_venv/lib/python3.8/site-packages/torch-1.8.1-py3.8-linux-x86_64.egg/torch/nn/modules/conv.py”, line 395, in _conv_forward
return F.conv2d(input, weight, bias, self.stride,
RuntimeError: Given groups=1, weight of size [64, 1, 3, 3], expected input[30, 3, 160, 600] to have 1 channels, but got 3 channels instead

May I request you to please tell me why I am getting this error since I am using the data provided? Also, please can you tell me how will I be able to use ‘-m pdb’ with opennmt since it is not working?

Thanks in advance!

Check this issue: