module 'tensorflow.keras.utils' has no attribute 'image_dataset_from_directory'
时间: 2023-10-10 13:08:00 浏览: 134
This error message suggests that the attribute 'image_dataset_from_directory' is not available in the 'utils' module of the TensorFlow Keras library.
This could be due to a few different reasons, such as using an outdated version of TensorFlow Keras or not importing the appropriate modules.
One possible solution is to update TensorFlow Keras to the latest version using the following command:
```
!pip install --upgrade tensorflow
```
If the issue persists, try importing the 'ImageDataGenerator' module instead and using it to generate image datasets from directories:
```
from tensorflow.keras.preprocessing.image import ImageDataGenerator
datagen = ImageDataGenerator(
# Specify image augmentation parameters
)
train_dataset = datagen.flow_from_directory(
# Specify training directory
)
test_dataset = datagen.flow_from_directory(
# Specify testing directory
)
```
阅读全文