Keras Entailment Example
See original GitHub issueI had a few doubts/questions about the Keras Entailment example
-
Why do we have to pass the model_dir? And if we don’t pass it, shouldn’t there be a default path? Also, it’s not being used in the
train
method at all - or is it? In the other methods it’s only loading from the directory passed, but I don’t think the train method (or any other method) is storing it anywhere - or am I missing something here? -
In the readme it asks for the directory for the training/evaluation, but what it needs is the path to the
json
file. Unless I’ve misunderstood something - it would be better to have this clarified on the readme (explicitly mentioning it needs a path to the son file). -
If you, for example, run either
demo
, orevaluate
, which need less parameters, it still throws up the: error: too few arguments
message. -
This could be because I’ve again, missed something somewhere - but when I run either evaluate or demo, I get this -
NameError: global name 'SimilarityModel' is not defined
from thespacy_hook
file. What exactly is supposed to be happening here? The training works fine, and so does the pytest.
[btw- the pytest
sometimes fails if you’re using a virtualenv
, where you’d have to re-install pytest
]
I wouldn’t mind opening a PR to make the documentation changes (if you think they would be helpful/necessary).
I’m in the process of making a jupyter notebook which tries to walkthrough all of this, because I think the information in the readme isn’t detailed enough about how to exactly get this to run. Also wanted demonstrate it (with some results).
Your Environment
- Operating System: OS X El Capitan
- Python Version Used: 2.7.12
- spaCy Version Used: 1.6.0
- Environment Information:
Issue Analytics
- State:
- Created 7 years ago
- Comments:18 (8 by maintainers)
Top GitHub Comments
I encountered this same problem and fixed it by selectively restoring part of an older version of keras. This commit:
https://github.com/fchollet/keras/commit/6417d90d5c1f70844d8d346312f1b40f449545a5#diff-56dc3cc42e1732fdb3a3c2c3c8efa32a
and this one:
https://github.com/fchollet/keras/commit/570fdf31c5cb9a580496d1d93320bc7ab1b9ad46#diff-56dc3cc42e1732fdb3a3c2c3c8efa32a
Introduces some code into keras/utils/generic_utils.py to allow for saving and re-loading of closures, but then this one:
https://github.com/fchollet/keras/commit/edae1785327dd7a418ac06c2fe85a8c1f6ea05b7#diff-56dc3cc42e1732fdb3a3c2c3c8efa32a
Removes the function that restores the closures. The comments on this commit claim that this was “broken” code, but it worked fine for me.
I just made sure that the functions related to closures were as in https://github.com/fchollet/keras/commit/570fdf31c5cb9a580496d1d93320bc7ab1b9ad46#diff-56dc3cc42e1732fdb3a3c2c3c8efa32a and this part worked.
Since this is obviously a bit unstable in keras right now, it would be better to see if this can be redone without closures.
(Also note that by default the example trains a model with max_length = 100 but uses max_length = 10 when running demo or evaluate. You’ll have to change one of these to make it work).
I got it working by applying this. Why this fix is not included in keras latest code ?