为什么验证数据很小?
当我使用以下代码将图像数据集分解为训练和验证时:
datagen_kwargs = dict(rescale=1./255, validation_split=.20)
valid_datagen = tf.keras.preprocessing.image.ImageDataGenerator(**datagen_kwargs)
valid_generator = valid_datagen.flow_from_directory(
TRAINING_DATA_DIR,
subset="validation",
shuffle=True,
target_size=IMAGE_SHAPE
)
train_datagen = tf.keras.preprocessing.image.ImageDataGenerator(**datagen_kwargs)
train_generator = train_datagen.flow_from_directory(
TRAINING_DATA_DIR,
subset="training",
shuffle=True,
target_size=IMAGE_SHAPE)
我得到以下输出:“找到属于 5 个类别的 1997 年图像。 找到属于 5 个类别的 7999 个图像。”
所以我的验证数据有 1997 个图像,训练数据有 7999 个图像。
现在,我尝试使用我训练的模型对验证数据进行预测。我使用 val_image_batch, val_label_batch = next (iter(valid_generator)) 当我打印 val_image_batch
或的长度时提取图像和标签。 val_label_batch
我得到的是 32,而不是 1997 -
我想对整个验证数据进行预测,而不仅仅是 32 个图像。有人可以帮我解决这个问题吗
?一个href="https://medium.com/analytics-vidhya/create-tensorflow-image-classification-model-with-your-own-dataset-in-google-colab-63e9d7853a3e" rel="nofollow noreferrer">文章< /a> 寻求帮助。
When I break by image dataset into train and validation using the following code:
datagen_kwargs = dict(rescale=1./255, validation_split=.20)
valid_datagen = tf.keras.preprocessing.image.ImageDataGenerator(**datagen_kwargs)
valid_generator = valid_datagen.flow_from_directory(
TRAINING_DATA_DIR,
subset="validation",
shuffle=True,
target_size=IMAGE_SHAPE
)
train_datagen = tf.keras.preprocessing.image.ImageDataGenerator(**datagen_kwargs)
train_generator = train_datagen.flow_from_directory(
TRAINING_DATA_DIR,
subset="training",
shuffle=True,
target_size=IMAGE_SHAPE)
I get the following output: "Found 1997 images belonging to 5 classes.
Found 7999 images belonging to 5 classes."
So my validation data has 1997 images and train data has 7999 images.
Now, I am trying to make predictions on the validation data using my trained model. I use val_image_batch, val_label_batch = next(iter(valid_generator))
to extract the images and labels. When I print the length of val_image_batch
or val_label_batch
I get 32 instead of 1997- the size of my validation data.
I want to make predictions on the entire validation data and not just 32 images. Can someone help me figure the problem?
I used this article for help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论