Up モデル読込みでのエラー 作成: 2021-04-20
更新: 2021-04-20


    先に保存していた モデル mnist.h5 を読み込む:
      (venv) $ python >>> from tensorflow.python.keras.models import load_model >>> model = load_model('./mnist.h5') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/pi/venv/lib/python3.7/site-packages/tensorflow_core/python/keras/saving/ save.py", line 146, in load_model return hdf5_format.load_model_from_hdf5(filepath, custom_objects, compile) File "/home/pi/venv/lib/python3.7/site-packages/tensorflow_core/python/keras/saving/ hdf5_format.py", line 166, in load_model_from_hdf5 model_config = json.loads(model_config.decode('utf-8')) AttributeError: 'str' object has no attribute 'decode'

    ネット検索で調べた限りでは,現時点でこのエラーの解決策はないようである。
    h5py のバージョンをいまの最新 (3.2.1) から 2.10.0 に変更するという論もあるが,これをすると,モデルのロードに先立つところの,モジュール load_model の import でエラーになる。