torchMoji
torchMoji copied to clipboard
ValueError: too many values to unpack (expected 2) error in example script
Hi,
I have cloned the repository and downloaded weights with given script. Then I have tried to run examples/text_emojize.py
with --text "Today is great'" --maxlen 30
, but it gave ValueError with following traceback:
➜ torchMoji git:(master) python3 examples/text_emojize.py --text "Today is great!" --maxlen 30
Traceback (most recent call last):
File "examples/text_emojize.py", line 55, in <module>
prob = model(tokenized)[0]
File "/Users/zafer/.pyenv/versions/3.6.7/lib/python3.6/site-packages/torch/nn/modules/module.py", line 547, in __call__
result = self.forward(*input, **kwargs)
File "/Users/repos/torchMoji/torchmoji/model_def.py", line 222, in forward
lstm_0_output, _ = self.lstm_0(packed_input, hidden)
File "/Users/zafer/.pyenv/versions/3.6.7/lib/python3.6/site-packages/torch/nn/modules/module.py", line 547, in __call__
result = self.forward(*input, **kwargs)
File "/Users/repos/torchMoji/torchmoji/lstm.py", line 78, in forward
input, batch_sizes = input
ValueError: too many values to unpack (expected 2)
My torch version is 1.2.0 and Python version is 3.6.7
I had the same problem, ~and solved it by using Python 3.5~
Sorry, I meant using torch==1.0.1 instead of the current default (1.5)
change
input, batch_sizes = input
to
input, batch_sizes ,_ ,_ = input
change input, batch_sizes = input to input, batch_sizes ,_ ,_ = input
@Nazieh Thank you so much for this! Such an obscure fix that no one has talked about...