This error occurs when trying to load weights from an HDF5 file using the `load_weights_from_hdf5_group_by_name` function in Keras. The error message suggests that the attribute `keras_version` in the HDF5 file is of type `str` and does not have a `decode` method.

To fix this issue, you can modify the `load_weights_from_hdf5_group_by_name` function in the Keras source code. Locate the line that reads `original_keras_version = f.attrs['keras_version'].decode('utf8')` and change it to `original_keras_version = str(f.attrs['keras_version'])`. This will convert the `str` attribute to a string before assigning it to `original_keras_version`.

After making this change, you can try loading the weights again.

Keras 'AttributeError: 'str' object has no attribute 'decode'' when Loading Weights from HDF5

原文地址: https://www.cveoy.top/t/topic/qfz0 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录