user11597888
user11597888

Reputation:

AttributeError: module 'tensorflow.io' has no attribute 'experimental'

I am trying to call a function from tensorflow to decode a tiff image, while i am running the notebook on kaggle notebooks and in this line:

img = tfio.experimental.image.decode_tiff(img, channels=1)

It gives me the error:

AttributeError: in user code:

<ipython-input-5-d30698f56813>:11 load  *
    img = tfio.experimental.image.decode_tiff(img, channels=1)

AttributeError: module 'tensorflow.io' has no attribute 'experimental'

I'm currently importing tensorflow.io like this:

import tensorflow.io as tfio

And my current version of: print(f"Tensorflow ver. {tf.__version__}") is

Tensorflow ver. 2.3.0

Upvotes: 4

Views: 6238

Answers (1)

desertnaut
desertnaut

Reputation: 60319

Tensorflow I/O does not come with Tensorflow, and it must be installed separately via pip; from the repo (emphasis mine):

TensorFlow I/O is a collection of file systems and file formats that are not available in TensorFlow's built-in support.

Moreover, it is not imported like that.

What you should do is install it via pip:

!pip install tensorflow-io

and verify that you get the latest version v0.15.0, as it is currently the only one compatible with TF 2.3 (source):

import tensorflow_io as tfio
tfio.__version__
# 0.15.0

Notice the different import - tensorflow_io, not tensorflow.io; this is demonstrated also in the simple usage examples in Github.

Upvotes: 5

Related Questions