-
Notifications
You must be signed in to change notification settings - Fork 40
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
Loading model does not work #28
Comments
The most relevant packages in that pip list I guess are:
|
On WSL (Windows Subsystem Linux), the same model load command gives: ---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-22-b568fbdcb1f4> in <module>()
----> 1 model = load_model('./model/model.h5')
/home/wmkouw/anaconda2/envs/mcfly/lib/python2.7/site-packages/keras/models.pyc in load_model(filepath, custom_objects, compile)
231 raise ValueError('No model found in config file.')
232 model_config = json.loads(model_config.decode('utf-8'))
--> 233 model = model_from_config(model_config, custom_objects=custom_objects)
234
235 # set weights
/home/wmkouw/anaconda2/envs/mcfly/lib/python2.7/site-packages/keras/models.pyc in model_from_config(config, custom_objects)
305 'Maybe you meant to use '
306 '`Sequential.from_config(config)`?')
--> 307 return layer_module.deserialize(config, custom_objects=custom_objects)
308
309
/home/wmkouw/anaconda2/envs/mcfly/lib/python2.7/site-packages/keras/layers/__init__.pyc in deserialize(config, custom_objects)
52 module_objects=globs,
53 custom_objects=custom_objects,
---> 54 printable_module_name='layer')
/home/wmkouw/anaconda2/envs/mcfly/lib/python2.7/site-packages/keras/utils/generic_utils.pyc 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'])
/home/wmkouw/anaconda2/envs/mcfly/lib/python2.7/site-packages/keras/models.pyc in from_config(cls, config, custom_objects)
1207 model = cls()
1208 for conf in config:
-> 1209 layer = layer_module.deserialize(conf, custom_objects=custom_objects)
1210 model.add(layer)
1211 return model
/home/wmkouw/anaconda2/envs/mcfly/lib/python2.7/site-packages/keras/layers/__init__.pyc in deserialize(config, custom_objects)
52 module_objects=globs,
53 custom_objects=custom_objects,
---> 54 printable_module_name='layer')
/home/wmkouw/anaconda2/envs/mcfly/lib/python2.7/site-packages/keras/utils/generic_utils.pyc 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'])
/home/wmkouw/anaconda2/envs/mcfly/lib/python2.7/site-packages/keras/layers/core.pyc in from_config(cls, config, custom_objects)
692 elif function_type == 'lambda':
693 # Unsafe deserialization from bytecode
--> 694 function = func_load(config['function'], globs=globs)
695 else:
696 raise TypeError('Unknown function type:', function_type)
/home/wmkouw/anaconda2/envs/mcfly/lib/python2.7/site-packages/keras/utils/generic_utils.pyc in func_load(code, defaults, closure, globs)
198 if isinstance(defaults, list):
199 defaults = tuple(defaults)
--> 200 code = marshal.loads(code.encode('raw_unicode_escape'))
201 if globs is None:
202 globs = globals()
ValueError: bad marshal data (unknown type code) Other sources suggest bad marshal data is due to discrepancies in Python versions: conda version 4.3.25, python version 2.7.13
backports-abc==0.5
backports.shutil-get-terminal-size==1.0.0
backports.ssl-match-hostname==3.5.0.1
backports.weakref==1.0rc1
bleach==1.5.0
certifi==2017.7.27.1
click==6.7
configparser==3.5.0
cycler==0.10.0
decorator==4.1.2
entrypoints==0.2.3
enum34==1.1.6
Flask==0.12.2
Flask-Cors==3.0.3
funcsigs==1.0.2
functools32==3.2.3.post2
gevent==1.2.2
greenlet==0.4.12
h5py==2.7.1
html5lib==0.9999999
ipykernel==4.6.1
ipython==5.5.0
ipython-genutils==0.2.0
ipywidgets==7.0.1
itsdangerous==0.24
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.6
Mako==1.0.7
Markdown==2.6.9
MarkupSafe==1.0
matplotlib==2.0.2
mcfly==1.0.1
mistune==0.7.4
mock==2.0.0
nbconvert==5.3.1
nbformat==4.4.0
notebook==5.1.0
numpy==1.13.1
olefile==0.44
pandas==0.20.3
pandocfilters==1.4.2
pathlib2==2.3.0
pbr==3.1.1
pexpect==4.2.1
pickleshare==0.7.4
Pillow==4.2.1
prompt-toolkit==1.0.15
protobuf==3.4.0
ptyprocess==0.5.2
Pygments==2.2.0
pygpu==0.7.1
pyparsing==2.2.0
python-dateutil==2.6.1
pytz==2017.2
PyYAML==3.12
pyzmq==16.0.2
qtconsole==4.3.1
quiver-engine==0.1.4.1.4
scandir==1.5
scikit-learn==0.19.0
scipy==0.19.1
simplegeneric==0.8.1
singledispatch==3.4.0.3
six==1.10.0
subprocess32==3.2.7
tensorflow==1.3.0
tensorflow-tensorboard==0.1.6
terminado==0.6
testpath==0.3.1
Theano==0.9.0
tornado==4.5.2
traitlets==4.3.2
wcwidth==0.1.7
webencodings==0.5
Werkzeug==0.12.2
widgetsnbextension==3.0.3 |
Fixed my problem by reverting to Python 3.5, as suggested here: https://github.com/fchollet/keras/issues/ @cwmeijer: might be nice to add this to the documentation. |
@egpbos could you correct the link, it points to list of all issues now? I have the same problem. Thanks :) |
Sorry, I don't remember the full link, does reverting to Python 3.5 not work for you @majthehero ? |
It works 👍 I didn't notice that you wrote that, thanks. |
It indeed seems to be inherent to Keras that models made+saved under python 3.5 often cannot be loaded under python 3.6. |
ValueError Traceback (most recent call last) ~\anaconda3\lib\site-packages\tensorflow\python\keras\saving\save.py in load_model(filepath, custom_objects, compile, options) ~\anaconda3\lib\site-packages\tensorflow\python\keras\saving\hdf5_format.py in load_model_from_hdf5(filepath, custom_objects, compile) ~\anaconda3\lib\site-packages\tensorflow\python\keras\saving\model_config.py in model_from_config(config, custom_objects) ~\anaconda3\lib\site-packages\tensorflow\python\keras\layers\serialization.py in deserialize(config, custom_objects) ~\anaconda3\lib\site-packages\tensorflow\python\keras\utils\generic_utils.py in deserialize_keras_object(identifier, module_objects, custom_objects, printable_module_name) ~\anaconda3\lib\site-packages\tensorflow\python\keras\engine\training.py in from_config(cls, config, custom_objects) ~\anaconda3\lib\site-packages\tensorflow\python\keras\engine\functional.py in from_config(cls, config, custom_objects) ~\anaconda3\lib\site-packages\tensorflow\python\keras\engine\functional.py in reconstruct_from_config(config, custom_objects, created_layers) ~\anaconda3\lib\site-packages\tensorflow\python\keras\engine\functional.py in process_layer(layer_data) ~\anaconda3\lib\site-packages\tensorflow\python\keras\layers\serialization.py in deserialize(config, custom_objects) ~\anaconda3\lib\site-packages\tensorflow\python\keras\utils\generic_utils.py in deserialize_keras_object(identifier, module_objects, custom_objects, printable_module_name) ~\anaconda3\lib\site-packages\tensorflow\python\keras\layers\core.py in from_config(cls, config, custom_objects) ~\anaconda3\lib\site-packages\tensorflow\python\keras\layers\core.py in _parse_function_from_config(cls, config, custom_objects, func_attr_name, module_attr_name, func_type_attr_name) ~\anaconda3\lib\site-packages\tensorflow\python\keras\utils\generic_utils.py in func_load(code, defaults, closure, globs) ValueError: bad marshal data (unknown type code) Im having this issue can anyone please tell how to solve this. |
In the tutorial, loading the pre-trained model does not work.
Gives:
This is on macOS, with conda Python 3.6.2.
pip freeze
gives the following list:The text was updated successfully, but these errors were encountered: