Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BI_LSTM-CRF examples not working #106

Open
soumandal opened this issue Jun 18, 2019 · 2 comments
Open

BI_LSTM-CRF examples not working #106

soumandal opened this issue Jun 18, 2019 · 2 comments

Comments

@soumandal
Copy link

If you open a GitHub issue, here is our policy:

  1. It must be a bug, a feature request, or a significant problem with documentation (for small docs fixes please send a PR instead).
  2. The form below must be filled out.

System information

  • Windows 10
  • Tensorflow 1.13/Keras 2.2.3
  • Python 3.7

Describe the problem

I am facing two problems

  1. While saving the BiLSTM-CRF model, the weights and the preprocessor files are being saved but not the params file.
  2. While testing, I am getting the error "AttributeError: type object 'BiLSTMCRF' has no attribute 'load'"

Source code / logs

from anago.tagger import Tagger
from anago.models import BiLSTMCRF
from anago.preprocessing import IndexTransformer
from pprint import pprint


def main():
    print('loading objects')
    model = BiLSTMCRF.load("weights.h5", "params.json")
    it = IndexTransformer.load("preprocessor.json")
    tagger = Tagger(model, preprocessor=it)

    print('tagging a sentence')
    res = tagger.analyze("EU rejects German call to boycott British lamb .")
    pprint(res)

if __name__ == main():
    main()

ERROR

Traceback (most recent call last):
File "C:/Users/soumil/PycharmProjects/code_switching/test.py", line 17, in
if name == main():
File "C:/Users/lab/PycharmProjects/code_switching/test.py", line 9, in main
model = BiLSTMCRF.load("weights.h5", "params.json")
AttributeError: type object 'BiLSTMCRF' has no attribute 'load'

@nikhiljsk
Copy link

I'm running into the same error. I use Python 3.6 BTW.

@kommerzienrat
Copy link

kommerzienrat commented Aug 12, 2019

You may have to use load_model:
from anago.models import load_model

Otherwise, you could use (for sequence models):
model = anago.Sequence.load(...)

cbilgili added a commit to cbilgili/anago that referenced this issue Aug 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants