Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'str' object has no attribute 'decode' for Tensorflow in Python [duplicate]

I want to run a code. It is written in Python3 using Tensorflow. I could run the code, but when the code was running, I tried to run another code with some changes in a separate Anaconda Prompt. Then I stopped the code. Now, when I try to run the similar code again without any changes, it gives me the following error:

AttributeError: 'str' object has no attribute 'decode'

The error refers to the tensorflow\python\keras package as follow:

hdf5_format.py. line 711, in load_weights_from_hdf5_group
original_keras_version = f.attrs['keras_version'].decode('utf8')

This is some parts of my code which rises the error:

self.encoder.load_weights(weights_file, by_name = True)

I closed the program and reopened it, but the error still exits.

Does anyone know how to solve it?

like image 608
Narcis Avatar asked Jan 25 '23 09:01

Narcis


1 Answers

The problem was solved by uninstalling h5py and installing h5py==2.10.0 as below:

pip uninstall h5py
pip install h5py==2.10.0

If h5py>3, the code shows the error.

like image 127
Narcis Avatar answered Jan 27 '23 00:01

Narcis