UPDATED - Further complications - ImportError: `load_weights` requires h5py

Viewed 648

I'm working with a previously saved model, however, when I try to load the model, I receive the following error message:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-11-f8d353bad309> in <module>
----> 1 estimator, corpus_encoder, label_encoder, tokenizer = load_model(MODEL_PATH, loss=weighted_binary_crossentropy)

<ipython-input-6-03f944f0a51f> in load_model(model_base_dir, loss, optimizer, metrics)
      9         json_file.close()
     10     model = model_from_json(loaded_model_json)
---> 11     model.load_weights(os.path.join(MODEL_PATH, 'model.h5'))
     12     model.compile(loss=loss, optimizer=optimizer, metrics=metrics)
     13     # loading context_encoder

~\anaconda3\envs\davis_env\lib\site-packages\keras\engine\network.py in load_weights(self, filepath, by_name, skip_mismatch, reshape)
   1154         """
   1155         if h5py is None:
-> 1156             raise ImportError('`load_weights` requires h5py.')
   1157         with h5py.File(filepath, mode='r') as f:
   1158             if 'layer_names' not in f.attrs and 'model_weights' in f:

ImportError: `load_weights` requires h5py.

I have since install cython and h5py as described in the answers found here and here

Are there any other solutions?

I'm using tensorflow version 1.12.0 and keras version 2.2.4

UPDATE:

When simply trying to import h5py (via ```import h5py``) I receive the following error message:

ImportError                               Traceback (most recent call last)
<ipython-input-15-c9f0b8c65221> in <module>
----> 1 import h5py

~\anaconda3\envs\davis_env\lib\site-packages\h5py\__init__.py in <module>
     32         raise
     33 
---> 34 from . import version
     35 
     36 if version.hdf5_version_tuple != version.hdf5_built_version_tuple:

~\anaconda3\envs\davis_env\lib\site-packages\h5py\version.py in <module>
     15 
     16 from collections import namedtuple
---> 17 from . import h5 as _h5
     18 import sys
     19 import numpy

h5py\h5.pyx in init h5py.h5()

ImportError: DLL load failed: The specified procedure could not be found.```




0 Answers
Related