This repository has been archived by the owner on Dec 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
[Suggestion] Add parameter mini_width
or something else to TokenCharactersIndexer
's initializer.
#1954
Comments
Yes, we've hit this issue multiple times, and I think adding a |
I am working on it. |
matt-gardner
pushed a commit
that referenced
this issue
Oct 26, 2018
* add min_padding_length to TokenCharactersIndexer (#1954) * mv min_padding_length to arg-list's end * add test_case for character_token_indexer_test * test min_padding_length * add test_case for character_token_indexer_test * test min_padding_length * delete annoying DOS crlf * delete unused variable * Remove trailing newlines
matt-gardner
pushed a commit
that referenced
this issue
Nov 7, 2018
Closed
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Describe the bug
I used a simple CNN on a text classification tasks. It worked well when training, but it broke when predicting.
To Reproduce
For convenience, I provide a test case at allennlp-demo-producing-bug.
Steps to reproduce the behavior
git clone https://github.com/WrRan/allennlp-demo-producing-bug.git demo
cd demo
Expected behavior
Because testdata is same as traindata, it is unexpected to get a RuntimeError.
(Moreover, the
predictor
used inallennlp predict
is trivial.)System (please complete the following information):
Additional context
I think the error comes from the
TokenCharactersIndexer
under some edge cases and default settings.The error is produced by the settings and a special datapoint:
The
cnn_encoders
with the setting:requires the word consisting of no less than 4 characters.
configs: https://github.com/WrRan/allennlp-demo-producing-bug/blob/685dcffd3755da60fe3fb360aa6f8338571ce86d/config/cnn_classifier.json#L49-L51
However, there is an unexpected datapoint:
I I I I I I I.
.Thus, prediction is broken.
But training process works well.
Why?
It is in that
batch_size
is set as64
, and the sentenceI I I I I I I.
is feed to model with another good sentenceThe allennlp is awesome.
. Under such case, classTokenCharactersIndexer
producespadding_lengths
of7
(which is the length of the wordawesome
in the batch).Suggestions
I think the key is the design of class
TokenCharactersIndexer
which producespadding_lengths
just taking consideration of single one datapoint. (in methodget_padding_lengths
).So it may be a good idea to add a parameter
mini_width
or something else toTokenCharactersIndexer
's initializer.In that case, we can config like this:
and the class
TokenCharactersIndexer
may work like this:Above solution copes with my issue. And I think no default value of
mini_width
is a better idea.Does this make sense?
Look forward to hearing from you. Thanks.
The text was updated successfully, but these errors were encountered: