UKPLab / emnlp2017-relation-extraction

Context-Aware Representations for Knowledge Base Relation Extraction
Apache License 2.0
289 stars 71 forks source link

got an unexpected keyword argument 'embeddings' #11

Closed shaburanigud closed 6 years ago

shaburanigud commented 6 years ago

When I try to recreate the training process I seem to get this error

python3 model_train.py model_ContextWeighted train-continue ../data/wikipedia-wikidata/enwiki-20160501/semantic-graphs-filtered-training.02_06.json ../data/wikipedia-wikidata/enwiki-20160501/semantic-graphs-filtered-validation.02_06.json /usr/local/lib/python3.5/dist-packages/h5py/init.py:36: FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type. from ._conv import register_converters as _register_converters Using TensorFlow backend. Loaded embeddings: (400002, 50) Loaded data size: 372059 Loaded data size: 123824 Training data size: 372059 Validation data size: 123824 Max sentence length set to: 36 Traceback (most recent call last): File "model_train.py", line 92, in embeddings=embedding_matrix, position2idx=keras_models.position2idx)) TypeError: to_indices_with_extracted_entities() got an unexpected keyword argument 'embeddings'

in which is caused by this part of the code in model_train.py

if "Context" in model_name: to_one_hot = embeddings.timedistributed_to_one_hot graphs_to_indices = keras_models.to_indices_with_extracted_entities elif "CNN" in model_name: graphs_to_indices = keras_models.to_indices_with_relative_positions

train_as_indices = list(graphs_to_indices(training_data, word2idx, max_sent_len,                                               embeddings=embedding_matrix, position2idx=keras_models.position2idx))
print("Dataset shapes: {}".format([d.shape for d in train_as_indices]))
training_data = None
n_out = len(keras_models.property2idx)
print("N_out:", n_out)

val_as_indices = list(graphs_to_indices(val_data, word2idx, max_sent_len,                                             embeddings=embedding_matrix, position2idx=keras_models.position2idx))
val_data = None

Would you mind giving any advice on how to fix this?

P.S. Line 92 refers to train_as_indices = list(graphs_to_indices(training_data, word2idx, max_sent_len, embeddings=embedding_matrix, position2idx=keras_models.position2idx))

P.S.2 Initially when I tried to run the code with "train-test" I found that it is an invalid choice. Unless I missed something, is the README currently outdated?

daniilsorokin commented 6 years ago

Thanks for the report! Yes, that was a bug, that was caused by a new signature for the data encoding methods. Try the latest version, please.

README was also updated.

daniilsorokin commented 6 years ago

Feel free to re-open if the problem persists.