spinn
spinn copied to clipboard
Cannot run code when following instructions: Assertion Error
Here and on the master branch whenever I pull I run into the same issue: File "/home/fbaturst/Desktop/spinn-listops-release1/python/spinn/util/data.py", line 51, in TrimDataset assert allow_cropping or diff == 0, "allow_eval_cropping is false but there are over-length eval examples." AssertionError: allow_eval_cropping is false but there are over-length eval examples.
I wouldn't like to change the existing code too much so I would be very grateful I someone could give some background on this issue. I haven't modified anything in the original code so far.
Best, Filip
It looks like you're evaluating on a dataset (maybe MultiNLI?) that has some very long sentences. You'll either need to increase --eval_seq_length to extend to the longest example in your evaluation data, or you'll need to set --allow_eval_cropping.
Are you getting this with the exact command in the readme?
The command is the one in the README yes:
PYTHONPATH=spinn/python
python3 -m spinn.models.supervised_classifier --data_type listops
--model_type RNN --training_data_path spinn/data/listops/train_d20s.tsv
--eval_data_path spinn/data/listops/test_d20s.tsv \
--word_embedding_dim 128 --model_dim 128 --seq_length 100 \
--eval_seq_length 3000 --mlp_dim 16 --num_mlp_layers 2
--optimizer_type Adam --experiment_name RNN_samplerun
And here is the exact terminal output:
It does not seem to recognize the eval_seq_length and word_embedding_dim commands.
Hrm—that's not the command that I see in the readme. It looks like the errors are coming from some deleted \ that should be there. That's just the command line syntax to indicate that the command continues on the next line.
Thank you for your feedback! I apologize, it seems there was a problem with my installation. I created a new Conda environment and did everything from scratch. I would like to note a couple of things that might be added, if I am not mistaken. To run one needs to have cython installed, which is not in the requirements.txt or automatically installed - furthermore since it is not specified which version of cython should be installed, I simply installed the newest one(I don't know if it matters though).
Upon doing so, there are still 2 quickly fixable problems that I encountered(again I am not sure is this is a problem only on my machine, and I have pytorch 0.4.0 installed, as recommended) in line 749 of spinn/util/blocks.py. One gets the following error
File "/home/fbaturst/Desktop/spinn-master/python/spinn/util/blocks.py", line 749, in ZeroInitializer param.data.set_(torch.from_numpy(init)) RuntimeError: set_storage is not allowed on Tensor created from .data or .detach()
which is fixed by changing 749 param.data.set_(torch.from_numpy(init)) to with torch.no_grad(): param.set_(torch.from_numpy(init))
And also in spinn/models/supervised_classifer.py I get the following error: File "/home/fbaturst/Desktop/spinn-master/python/spinn/models/supervised_classifier.py", line 280, in train_loop A.add('xent_cost', xent_loss.data[0]) IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number
Which is fixed by changing line 280 from: A.add('xent_cost', xent_loss.data[0]) to A.add('xent_cost', xent_loss.item())
Again I don't know if this is an error on my behalf again, but after this is fixed everything seems to run smoothly. Please let me know what you think!