Skip to content

Unable to run demo of keras_parikh_entailment example through python #2371

@ghost

Description

Hello, I trained the model using the keras_parikh_entailment example. Training was successful, and files were stored in the destination properly.

However, while trying to run demo on the model, whenever I try to execute the following line,
nlp = spacy.load("en", path=model_path, create_pipeline=create_similarity_pipeline)
I get the following error:


TypeError Traceback (most recent call last)
in ()
----> 1 nlp = spacy.load("en", path=model_path, create_pipeline=create_similarity_pipeline)

~/Software/anaconda2/envs/keras_parikh/lib/python3.5/site-packages/spacy/init.py in load(name, **overrides)
40 overrides['meta'] = meta
41 overrides['path'] = model_path
---> 42 return cls(**overrides)

~/Software/anaconda2/envs/keras_parikh/lib/python3.5/site-packages/spacy/en/init.py in init(self, **overrides)
32 # Special-case hack for loading the GloVe vectors, to support <1.0
33 overrides = fix_glove_vectors_loading(overrides)
---> 34 Language.init(self, **overrides)

~/Software/anaconda2/envs/keras_parikh/lib/python3.5/site-packages/spacy/language.py in init(self, **overrides)
295 self.pipeline = overrides['pipeline']
296 elif 'create_pipeline' in overrides:
--> 297 self.pipeline = overrides'create_pipeline'
298 else:
299 self.pipeline = [self.tagger, self.parser, self.matcher, self.entity]

~/spaCy/examples/keras_parikh_entailment/spacy_hook.py in create_similarity_pipeline(nlp, max_length)
86 nlp.entity,
87 nlp.parser,
---> 88 KerasSimilarityShim.load(nlp.path / 'similarity', nlp, max_length)
89 ]

~/spaCy/examples/keras_parikh_entailment/spacy_hook.py in load(cls, path, nlp, get_features, max_length)
17 get_features = get_word_ids
18 with (path / 'config.json').open() as file_:
---> 19 model = model_from_json(file_.read())
20 with (path / 'model').open('rb') as file_:
21 weights = pickle.load(file_)

~/Software/anaconda2/envs/keras_parikh/lib/python3.5/site-packages/keras/models.py in model_from_json(json_string, custom_objects)
211 from keras.utils.layer_utils import layer_from_config
212 config = json.loads(json_string)
--> 213 return layer_from_config(config, custom_objects=custom_objects)
214
215

~/Software/anaconda2/envs/keras_parikh/lib/python3.5/site-packages/keras/utils/layer_utils.py in layer_from_config(config, custom_objects)
38 if 'custom_objects' in arg_spec.args:
39 return layer_class.from_config(config['config'],
---> 40 custom_objects=custom_objects)
41 else:
42 return layer_class.from_config(config['config'])

~/Software/anaconda2/envs/keras_parikh/lib/python3.5/site-packages/keras/engine/topology.py in from_config(cls, config, custom_objects)
2580
2581 for layer_data in config['layers']:
-> 2582 process_layer(layer_data)
2583
2584 name = config.get('name')

~/Software/anaconda2/envs/keras_parikh/lib/python3.5/site-packages/keras/engine/topology.py in process_layer(layer_data)
2558 # Instantiate layer.
2559 layer = layer_from_config(layer_data,
-> 2560 custom_objects=custom_objects)
2561 created_layers[layer_name] = layer
2562

~/Software/anaconda2/envs/keras_parikh/lib/python3.5/site-packages/keras/utils/layer_utils.py in layer_from_config(config, custom_objects)
38 if 'custom_objects' in arg_spec.args:
39 return layer_class.from_config(config['config'],
---> 40 custom_objects=custom_objects)
41 else:
42 return layer_class.from_config(config['config'])

~/Software/anaconda2/envs/keras_parikh/lib/python3.5/site-packages/keras/layers/core.py in from_config(cls, config, custom_objects)
680 function = get_from_module(config['function'], globs, 'core')
681 elif function_type == 'lambda':
--> 682 function = func_load(config['function'], globs=globs)
683 else:
684 raise TypeError('Unknown function type:', function_type)

~/Software/anaconda2/envs/keras_parikh/lib/python3.5/site-packages/keras/utils/generic_utils.py in func_load(code, defaults, closure, globs)
187 name=code.co_name,
188 argdefs=defaults,
--> 189 closure=closure)
190
191

TypeError: arg 5 (closure) must be None or tuple

Can anyone please tell me what's happening here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    examplesCode examples in /examples

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions