[SOLVED] TensorFlow: AttributeError: module ‘tensorflow’ has no attribute ‘read_file’

1. The problem

The tf.read_file function has no been support longer and when you execute the code like below:

import tensorflow as tf

img_raw = tf.read_file(img_path)
print(repr(img_raw)[:100]+"…")

You get the following exception:

AttributeError: module 'tensorflow' has no attribute 'read_file'

2. The solution

The function has been move into tensorflow.io module. You should change your code like it was done below:

import tensorflow as tf

img_raw = tf.io.read_file(img_path)
print(repr(img_raw)[:100]+"…")
At the end… May I ask you for something?

If I helped you solve your problem, please share this post. Thanks to this, I will have the opportunity to reach a wider group of readers. Thank You

Leave a Reply

avatar
  Subscribe  
Notify of
Close Menu