Getting attribute error when using AUTOTUNE in Tensorflow?

I am using AUTOTUNE for audio processing.

import tensorflow as tf
AUTOTUNE = tf.data.AUTOTUNE

But i am getting attribute error which said "module 'tensorflow._api.v2.data' has no attribute 'AUTOTUNE'". Tensorflow version is 2.3.0. How to solve this?


Solution 1:

According to the TensorFlow 2.3 documentation, AUTOTUNE lies under the tensorflow.data.experimental namespace. So using

AUTOTUNE = tf.data.experimental.AUTOTUNE

should avoid this error.