YoungXiyuan/DCA

self.ent_inlinks = config['entity_inlinks'] KeyError: 'entity_inlinks

Opened this issue · 2 comments

python main.py --mode train --order offset --model_path model --method RL
是可以执行成功的。
但是eval 的时候报错。

python main.py --mode eval --order offset --model_path model --method RL

root@:/data/DCA$ ~/.conda/envs/keras_bert/bin/python main.py --mode eval --order offset --model_path model --method RL
load conll at ../data/generated/test_train_data
load csv
370United News of India
process coref
load conll
reorder mentions within the dataset
create model
--- create EDRanker model ---
prerank model
--- create NTEE model ---
--- create AbstractWordEntity model ---
main model
try loading model from model
--- create MulRelRanker model ---
--- create LocalCtxAttRanker model ---
--- create AbstractWordEntity model ---
Traceback (most recent call last):
File "main.py", line 204, in
ranker = EDRanker(config=config)
File "../DCA/ed_ranker.py", line 52, in init
self.model = load_model(self.args.model_path, ModelClass)
File "../DCA/abstract_word_entity.py", line 28, in load
model = model_class(config)
File "../DCA/mulrel_ranker.py", line 32, in init
self.ent_inlinks = config['entity_inlinks']

data 目录下是这样的:
ll data
total 135990
drwxrwxr-x 1 mqq mqq 108039782 Nov 6 2018 basic_data
drwxrwxr-x 1 mqq mqq 6472491 Nov 6 2018 data
-rw-rw-r-- 1 mqq mqq 1245609 Aug 20 2019 doc2type.pkl
-rw-rw-r-- 1 mqq mqq 120266616 May 18 2019 ent2desc.json
-rw-rw-r-- 1 mqq mqq 9864329 Aug 20 2019 entity2type.pkl
-rw-rw-r-- 1 mqq mqq 7869649 Aug 20 2019 entityid_dictid_inlinks_uniq.pkl
drwxrwxr-x 1 mqq mqq 2251141855 Jan 23 2019 generated
-rw-rw-r-- 1 mqq mqq 5862 Aug 20 2019 stopwords-multi.txt
-rw-rw-r-- 1 mqq mqq 82 Aug 20 2019 symbols.txt
drwxrwxr-x 1 mqq mqq 21420384 Nov 6 2018 test_data
drwxrwxr-x 1 mqq mqq 898623014 Nov 6 2018 word_ent_embs

麻烦看下,谢谢。

Thank you for your interest in our work (:

First, the mode "train" might be enough, for that it would involve the evaluation process after certain epochs set in the parameter "eval_after_n_epochs".

Second, the error that you report might be caused by the old version of mode "eval" implementation.

To solve that error, you could pass the "Dict config" into the function "load_model(..., config)" in the line #52 of "ed_ranker.py", and modify the function "load(...)" in the line #16 of "abstract_word_entity.py" to accept that dict variable, like "load(..., outer_config)"

Then in the function body of "load(..., outer_config)", you could write the following assignment, like "config['entity_inlinks'] = outer_config['entity_inlinks']" between the line #20 and line #28.

I guess the above solution might work, give it a try (:

Yes, I've got a similar error too with a trained model.

File "main.py", line 204, in <module>
ranker = EDRanker(config=config)
File "../DCA/ed_ranker.py", line 52, in __init__
self.model = load_model(self.args.model_path, ModelClass)
File "../DCA/abstract_word_entity.py", line 28, in load
model = model_class(config)
File "../DCA/mulrel_ranker.py", line 32, in __init__
self.ent_inlinks = config['entity_inlinks']