gpt4 book ai didi

tensorflow - 在 tensorflow 中加载 image_dataset_from_directory 时出错?

转载 作者:行者123 更新时间:2023-12-03 14:06:58 24 4
gpt4 key购买 nike

这是代码
来自 https://keras.io/examples/vision/image_classification_from_scratch/

import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers

# generate a dataset
image_size = (180,180)
batch_size = 32

train_ds = tf.keras.preprocessing.image_dataset_from_directory(
"PetImages",
validation_split = 0.2,
subset = "training",
seed = 1337,
image_size = image_size,
batch_size = batch_size,
)

错误是
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-21-bb7f2d14bf63> in <module>
3 batch_size = 32
4
----> 5 train_ds = tf.keras.preprocessing.image_dataset_from_directory(
6 "PetImages",
7 validation_split = 0.2,

AttributeError: module 'tensorflow.keras.preprocessing' has no attribute 'image_dataset_from_directory'

我现在忽略的任何最小细节?

最佳答案

它已在 this issue 下得到解决.
The specific function (tf.keras.preprocessing.image_dataset_from_directory) is not available under TensorFlow v2.1.x or v2.2.0 yet. It is only available with the tf-nightly builds and is existent in the source code of the master branch.
太糟糕了,他们没有在现场的任何地方注明。更好用 flow_from_directory目前。或转至 tf-nightly并继续。

关于tensorflow - 在 tensorflow 中加载 image_dataset_from_directory 时出错?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62409838/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com