简体   繁体   中英

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,
)

I used the above function for loading the dataset and preprocessing it. How can I view the data returned by the function? print(data) is returning the address of the created object, even transforming it to a numpy array is not working.

Try:

image_batch, label_batch = next(iter(data))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM