[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]+"…")
If the article was helpful to you, you can support me by:

Leave a Reply

avatar
  Subscribe  
Notify of
Close Menu