Skip to content

Loading model does not work #28

@egpbos

Description

@egpbos

In the tutorial, loading the pre-trained model does not work.

model = load_model('./model/model.h5')

Gives:

---------------------------------------------------------------------------
SystemError                               Traceback (most recent call last)
<ipython-input-26-5d87631adf41> in <module>()
----> 1 model = load_model('./model/model.h5')

~/sw/miniconda3/envs/mcfly-tutorial/lib/python3.6/site-packages/keras/models.py in load_model(filepath, custom_objects, compile)
    237             raise ValueError('No model found in config file.')
    238         model_config = json.loads(model_config.decode('utf-8'))
--> 239         model = model_from_config(model_config, custom_objects=custom_objects)
    240 
    241         # set weights

~/sw/miniconda3/envs/mcfly-tutorial/lib/python3.6/site-packages/keras/models.py in model_from_config(config, custom_objects)
    311                         'Maybe you meant to use '
    312                         '`Sequential.from_config(config)`?')
--> 313     return layer_module.deserialize(config, custom_objects=custom_objects)
    314 
    315 

~/sw/miniconda3/envs/mcfly-tutorial/lib/python3.6/site-packages/keras/layers/__init__.py in deserialize(config, custom_objects)
     52                                     module_objects=globs,
     53                                     custom_objects=custom_objects,
---> 54                                     printable_module_name='layer')

~/sw/miniconda3/envs/mcfly-tutorial/lib/python3.6/site-packages/keras/utils/generic_utils.py in deserialize_keras_object(identifier, module_objects, custom_objects, printable_module_name)
    137                 return cls.from_config(config['config'],
    138                                        custom_objects=dict(list(_GLOBAL_CUSTOM_OBJECTS.items()) +
--> 139                                                            list(custom_objects.items())))
    140             with CustomObjectScope(custom_objects):
    141                 return cls.from_config(config['config'])

~/sw/miniconda3/envs/mcfly-tutorial/lib/python3.6/site-packages/keras/models.py in from_config(cls, config, custom_objects)
   1212         for conf in config:
   1213             layer = layer_module.deserialize(conf, custom_objects=custom_objects)
-> 1214             model.add(layer)
   1215         return model
   1216 

~/sw/miniconda3/envs/mcfly-tutorial/lib/python3.6/site-packages/keras/models.py in add(self, layer)
    473                           output_shapes=[self.outputs[0]._keras_shape])
    474         else:
--> 475             output_tensor = layer(self.outputs[0])
    476             if isinstance(output_tensor, list):
    477                 raise TypeError('All layers in a Sequential model '

~/sw/miniconda3/envs/mcfly-tutorial/lib/python3.6/site-packages/keras/engine/topology.py in __call__(self, inputs, **kwargs)
    600 
    601             # Actually call the layer, collecting output(s), mask(s), and shape(s).
--> 602             output = self.call(inputs, **kwargs)
    603             output_mask = self.compute_mask(inputs, previous_mask)
    604 

~/sw/miniconda3/envs/mcfly-tutorial/lib/python3.6/site-packages/keras/layers/core.py in call(self, inputs, mask)
    648         if has_arg(self.function, 'mask'):
    649             arguments['mask'] = mask
--> 650         return self.function(inputs, **arguments)
    651 
    652     def compute_mask(self, inputs, mask=None):

~/sw/miniconda3/envs/mcfly-tutorial/lib/python3.6/site-packages/keras/layers/core.py in <lambda>(x)
    176 
    177     # Input shape
--> 178         4D tensor with shape:
    179         `(samples, channels, rows, cols)` if data_format='channels_first'
    180         or 4D tensor with shape:

SystemError: unknown opcode

This is on macOS, with conda Python 3.6.2. pip freeze gives the following list:

appnope==0.1.0
bleach==1.5.0
certifi==2016.2.28
cycler==0.10.0
decorator==4.1.2
entrypoints==0.2.3
h5py==2.7.0
html5lib==0.9999999
ipykernel==4.6.1
ipython==6.1.0
ipython-genutils==0.2.0
ipywidgets==6.0.0
jedi==0.10.2
Jinja2==2.9.6
jsonschema==2.6.0
jupyter==1.0.0
jupyter-client==5.1.0
jupyter-console==5.2.0
jupyter-core==4.3.0
Keras==2.0.8
Markdown==2.6.9
MarkupSafe==1.0
matplotlib==2.0.2
mcfly==1.0.1
mistune==0.7.4
nbconvert==5.2.1
nbformat==4.4.0
notebook==5.0.0
numpy==1.13.1
pandas==0.20.3
pandocfilters==1.4.2
pexpect==4.2.1
pickleshare==0.7.4
prompt-toolkit==1.0.15
protobuf==3.4.0
ptyprocess==0.5.2
Pygments==2.2.0
pyparsing==2.2.0
python-dateutil==2.6.1
pytz==2017.2
PyYAML==3.12
pyzmq==16.0.2
qtconsole==4.3.1
scikit-learn==0.19.0
scipy==0.19.1
simplegeneric==0.8.1
six==1.10.0
tensorflow==1.3.0
tensorflow-tensorboard==0.1.6
terminado==0.6
testpath==0.3
tornado==4.5.2
traitlets==4.3.2
wcwidth==0.1.7
Werkzeug==0.12.2
widgetsnbextension==3.0.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions