1
$\begingroup$

I'm having a problem when loading a model in keras:

model = load_model('model.h5', custom_objects={'mean_iou': metrics.mean_iou})

As an error I get:

   ~/anaconda3/envs/idcard/lib/python3.6/site-packages/keras/engine/saving.py in load_model(filepath, custom_objects, compile)
    417     f = h5dict(filepath, 'r')
    418     try:
--> 419         model = _deserialize_model(f, custom_objects, compile)
    420     finally:
    421         if opened_new_file:

~/anaconda3/envs/idcard/lib/python3.6/site-packages/keras/engine/saving.py in _deserialize_model(f, custom_objects, compile)
    249         layer_weights = model_weights_group[name]
    250         weight_names = layer_weights['weight_names']
--> 251         if weight_names:
    252             filtered_layer_names.append(name)
    253 

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Does anyone have a clue why I'm getting this error?

$\endgroup$
1
$\begingroup$

It turns out that the solution to this problem is in the version of h5py.

If you have h5py == 3.1.* then you need to downgraded it to h5py == 2.10.0

Version of Keras needs to be 2.2.4

Or you can upgrade the version of Keras to 2.2.5

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.