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

elit/nlp/dep/parser/common/data.py #32

Open
imgarylai opened this issue Nov 28, 2018 · 5 comments
Open

elit/nlp/dep/parser/common/data.py #32

imgarylai opened this issue Nov 28, 2018 · 5 comments
Assignees
Labels

Comments

@imgarylai
Copy link
Member

word_dims = len(data)

...
elit_dep_biaffine_en_mixed.load('{}/data/model/dep/jumbo-fasttext100'.format(ELIT_PATH))
  File "/usr/local/lib/python3.5/dist-packages/elit/nlp/dep/parser/parser.py", line 168, in load
    self._parser = self._create_parser(self._config, self._vocab)
  File "/usr/local/lib/python3.5/dist-packages/elit/nlp/dep/parser/parser.py", line 209, in _create_parser
    config.mlp_rel_size, config.dropout_mlp, config.debug)
  File "/usr/local/lib/python3.5/dist-packages/elit/nlp/dep/parser/biaffine_parser.py", line 55, in __init__
    trainable=False) if vocab.has_pret_embs() else None
  File "/usr/local/lib/python3.5/dist-packages/elit/nlp/dep/parser/common/data.py", line 174, in get_pret_embs
    word_dims = len(data)
UnboundLocalError: local variable 'data' referenced before assignment
@hankcs
Copy link
Contributor

hankcs commented Nov 28, 2018

The embedding file in config.ini is referring to /home/zyang68/data/trained_embeddings/dim100.vec.bak. Now I changed it to data/embedding/fasttext100.vec.txt. Please use the new config.ini in ~/elit/data/model/dep/jumbo-fasttext100.

@imgarylai
Copy link
Member Author

Files have been updated but same errors.
Information below are from server, not from ainos.

$ cat /resources/elit/data/model/dep/jumbo-fasttext100/config.ini
[Data]
pretrained_embeddings_file = data/embedding/fasttext100.vec.txt
data_dir = data/dat
train_file = %(data_dir)s/en-ddr.trn.conllx
dev_file = %(data_dir)s/en-ddr.dev.conllx
test_file = %(data_dir)s/en-ddr.tst.conllx
min_occur_count = 2

[Save]
save_dir = data/model/dep/jumbo-fasttext100
config_file = %(save_dir)s/config.ini
save_model_path = %(save_dir)s/model.txt
save_vocab_path = %(save_dir)s/vocab.pkl

[Network]
lstm_layers = 3
char_dims = 0
word_dims = 100
tag_dims = 100
dropout_emb = 0.33
lstm_hiddens = 400
dropout_lstm_input = 0.33
dropout_lstm_hidden = 0.33
mlp_arc_size = 500
mlp_rel_size = 100
dropout_mlp = 0.33

[Optimizer]
learning_rate = 2e-3
decay = .75
decay_steps = 5000
beta_1 = .9
beta_2 = .9
epsilon = 1e-12

[Run]
num_buckets_train = 40
num_buckets_valid = 10
num_buckets_test = %(num_buckets_train)s
train_iters = 50000
train_batch_size = 5000
test_batch_size = %(train_batch_size)s
validate_every = 100
save_after = 5000
debug = false
$ ls data/embedding/
fasttext100.vec.txt  flair.vec.txt  glove  glove.6B.100d.debug.txt  glove.6B.100d.txt

@hankcs
Copy link
Contributor

hankcs commented Nov 29, 2018

Yes, I updated the first line data/embedding/fasttext100.vec.txt to %(data_dir)s/data/embedding/fasttext100.vec.txt. Now it should work.

@imgarylai
Copy link
Member Author

imgarylai commented Dec 12, 2018

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/wsgi.py", line 142, in __call__
    response = self.get_response(request)
  File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py", line 78, in get_response
    response = self._middleware_chain(request)
  File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/exception.py", line 36, in inner
    response = response_for_exception(request, exc)
  File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/exception.py", line 90, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/exception.py", line 128, in handle_uncaught_exception
    callback, param_dict = resolver.resolve_error_handler(500)
  File "/usr/local/lib/python3.5/dist-packages/django/urls/resolvers.py", line 546, in resolve_error_handler
    callback = getattr(self.urlconf_module, 'handler%s' % view_type, None)
  File "/usr/local/lib/python3.5/dist-packages/django/utils/functional.py", line 37, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/usr/local/lib/python3.5/dist-packages/django/urls/resolvers.py", line 526, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 665, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "./config/urls.py", line 23, in <module>
    path('api/', include('api.urls')),
  File "/usr/local/lib/python3.5/dist-packages/django/urls/conf.py", line 34, in include
    urlconf_module = import_module(urlconf_module)
  File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 665, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "./api/urls.py", line 18, in <module>
    from api import views
  File "./api/views.py", line 11, in <module>
    from api.components.elit import elit_tok_lexrule_en, elit_dep_biaffine_en_mixed, get_ctx
  File "./api/components/elit.py", line 71, in <module>
    elit_dep_biaffine_en_mixed.load('{}/data/model/dep/jumbo-fasttext100'.format(ELIT_PATH))
  File "/usr/local/lib/python3.5/dist-packages/elit/nlp/dep/parser/parser.py", line 168, in load
    self._parser = self._create_parser(self._config, self._vocab)
  File "/usr/local/lib/python3.5/dist-packages/elit/nlp/dep/parser/parser.py", line 209, in _create_parser
    config.mlp_rel_size, config.dropout_mlp, config.debug)
  File "/usr/local/lib/python3.5/dist-packages/elit/nlp/dep/parser/biaffine_parser.py", line 55, in __init__
    trainable=False) if vocab.has_pret_embs() else None
  File "/usr/local/lib/python3.5/dist-packages/elit/nlp/dep/parser/common/data.py", line 157, in get_pret_embs
    with open(self._pret_file) as f:
FileNotFoundError: [Errno 2] No such file or directory: 'data/embedding/fasttext100.vec.txt'

This place still use project relative path.

Please make sure all the paths in the setting are not project relative path.

@hankcs
Copy link
Contributor

hankcs commented Dec 23, 2018

Hi Gary, sorry for the delay, just survived final weeks. In this patch, we can override the embedding path:

parser.load(model_path, embedding_path)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants