-
Notifications
You must be signed in to change notification settings - Fork 2.2k
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Training error in forward() method #2528
Comments
The simple tagger is expecting an argument called |
Thanks for your quick answer! I use a custom dataset reader and it seems, there is something going wrong since the newer AllenNLP versions. |
@bianca2319 i get the same issue when I try feeding in a new data to the simple tagger. How did you solve this? Why was this closed btw? |
update: so i found what was happening in my case. Posting it here just in case this helps someone. So looks like in allennlp, they enforce you to use the same names of the fields you defined while reading the data. For example in the snli reader they were using the name In my case my fields instance (which had a TextField,TextField, LabelField, just like SNLI data) was called While I agree its a good thing to enforce the usage of same title field everywhere, but in a fluid plug and play environment like this I wish it wasn't enforced. Even if it was I wish this was atleast documented more clearly. I wasted couple of days trying to figure this out. |
I am sorry you ran into issues with this, but it is covered in the tutorial: https://allennlp.org/tutorials
If that's not clear enough, I'm happy to make changes to it, do you have any suggestions? (I feel like we also had an issue around programatically renaming fields to make it easier to mix and match dataset readers and models, although now I can't find the issue.) |
but also I'm curious how you expected the library to behave? that is, if I have an instance that looks like
and then a model whose forward function looks like
what would you expect to happen? how would you expect the library to decide which field should be "d", which should be "e", and which should be "f" if the names don't match? |
@joelgrus On second thoughts: regarding passing the arguments, you are right and am wrong. Though one humble suggestion is to maybe elaborate a little more in the documentation. i.e instead of |
When I try to train a model based on "default" trainer and "simple_tagger", I always get the following error message:
File "/home/bianca/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
TypeError: forward() got an unexpected keyword argument 'labels'
System:
Are there any ideas how to solve it?
The text was updated successfully, but these errors were encountered: