Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
aws-taylor opened this issue Dec 7, 2020 · 2 comments
Closed

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

aws-taylor opened this issue Dec 7, 2020 · 2 comments

Comments

@aws-taylor
Copy link
Contributor

When attempting to run the Keras Resnet50 tutorial, I received the following error:

import sys
!{sys.executable} aws-neuron-sdk/src/examples/tensorflow/keras_resnet50/gen_resnet50_keras.py

Output:

WARNING:tensorflow:From /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages/tensorflow_core/python/ops/resource_variable_ops.py:1630: calling BaseResourceVariable.__init__ (from tensorflow.python.ops.resource_variable_ops) with constraint is deprecated and will be removed in a future version.
Instructions for updating:
If using Keras pass *_constraint arguments to layers.
Downloading data from https://github.com/keras-team/keras-applications/releases/download/resnet/resnet50_weights_tf_dim_ordering_tf_kernels.h5
102973440/102967424 [==============================] - 5s 0us/step
Traceback (most recent call last):
  File "aws-neuron-sdk/src/examples/tensorflow/keras_resnet50/gen_resnet50_keras.py", line 35, in <module>
    model = ResNet50(weights='imagenet')
  File "/home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages/tensorflow_core/python/keras/applications/__init__.py", line 49, in wrapper
    return base_fun(*args, **kwargs)
  File "/home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages/tensorflow_core/python/keras/applications/resnet.py", line 33, in ResNet50
    return resnet.ResNet50(*args, **kwargs)
  File "/home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages/keras_applications/resnet_common.py", line 435, in ResNet50
    **kwargs)
  File "/home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages/keras_applications/resnet_common.py", line 411, in ResNet
    model.load_weights(weights_path)
  File "/home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/training.py", line 182, in load_weights
    return super(Model, self).load_weights(filepath, by_name)
  File "/home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/network.py", line 1373, in load_weights
    saving.load_weights_from_hdf5_group(f, self.layers)
  File "/home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages/tensorflow_core/python/keras/saving/hdf5_format.py", line 645, in load_weights_from_hdf5_group
    original_keras_version = f.attrs['keras_version'].decode('utf8')
AttributeError: 'str' object has no attribute 'decode'

The issue appears to be related to the h5py library when using the following version:

import sys
!{sys.executable} -m pip show h5py

Output:

Name: h5py
Version: 3.1.0
Summary: Read and write HDF5 files from Python
Home-page: http://www.h5py.org
Author: Andrew Collette
Author-email: andrew.collette@gmail.com
License: BSD
Location: /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages
Requires: cached-property, numpy
Required-by: Keras-Applications

If I downgrade to 2.9.0, things seem to work fine.

import sys
!{sys.executable} -m pip install h5py==2.9.0

I also came across this issue that may be related - tensorflow/tensorflow#44467

@aws-joshim
Copy link
Contributor

Please refer to the release note @ https://awsdocs-neuron.readthedocs-hosted.com/en/latest/release-notes/tensorflow-neuron/tensorflow-neuron.html, this issue can be addressed by downgrade h5py by pip install ‘h5py<3’.

@aws-joshim
Copy link
Contributor

Closing since this is fixed with the h5py<3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants