AttributeError: module 'tensorflow.keras' has no attribute 'utils_dataset_from_directory'

I am running tensorflow-macos and tensorflow-metal on Big Sur.

I am getting this error: AttributeError: module 'tensorflow.keras' has no attribute 'utils_dataset_from_directory'

Can I install tf_nightly? Or does it conflict with tensorflow-macos?

from tensorflow import keras
from tensorflow.python.framework.ops import disable_eager_execution
dataset = keras.utils_dataset_from_directory(
    image_size=(64, 64),

AttributeError                            Traceback (most recent call last)
/var/folders/3n/56fpv14n4wj0c1l1sb106pzw0000gn/T/ipykernel_41859/ in <module>
      1 from tensorflow import keras
      2 from tensorflow.python.framework.ops import disable_eager_execution
----> 3 dataset = keras.utils_dataset_from_directory(
      4     "celeba_gan",
      5     label_mode=None,

AttributeError: module 'tensorflow.keras' has no attribute 'utils_dataset_from_directory'


You are correct, tf_nightly (this is TF master, => v2.7) will conflict with tensorflow-macos (this is based on v2.5). There are also major changes in keras with latest release which is part of core TF:

I tried running with tf-nightly and ran into similar issue.