如何查看keras的image_dataset_from_directory函数生成的数据集?

How to view the dataset generated by the image_dataset_from_directory function of keras?

import numpy as np
import os
import random
import tensorflow as tf
from tensorflow import keras
import matplotlib.pyplot as plt
%matplotlib inline

CATEGORIES = ['cat', 'dog']

data = keras.preprocessing.image_dataset_from_directory(
    'train',
    labels = "inferred",
    label_mode = "int",
    class_names = ['cat', 'dog'],
    color_mode = "rgb",
    batch_size = 32,
    image_size = (256, 256),
    shuffle = True,
    seed = 42,
    validation_split = None,
    subset = None,
    interpolation = "bilinear",
    follow_links = False,
)

我使用上面的函数来加载数据集并对其进行预处理。如何查看函数返回的数据? print(data) 正在返回创建对象的地址,即使将其转换为 numpy 数组也不起作用。

尝试:

image_batch, label_batch = next(iter(data))