I have used keras' ImageDataGenerator to create labelled data by following the example in Ch 5 in Francois Chollet's book "Deep Learning with Python." As an example, I subdivided my training directory into cat and dog subdirectories, and then populated it with images. Using the following code, I created a variable that I believe contains both the image and the label.
from keras.preprocessing.image import ImageDataGenerator
train_datagen = ImageDataGenerator(rescale = 1./255)
train_generator = train_datagen.flow_from_directory(
train_dir,
target_size = (150, 150)
batch_size = 20,
class_mode = 'binary')
Later on , after defining a model, you would use the following code to run the model
history = model.fit_generator(
train_generator,
steps_per_epoch = 100,
epochs =30,
validation_data = validation_generator,
validation_step=50)
Many online examples of Neural Networks have separate variables that hold the test and training data (e.g. x_train, y_train, x_test, y_test). This seems the most popular method. As an example:
(x_train, y_train), (x_test, y_test) = mnist.load_data()
And you would run the model with the following code:
history = model.fit(x_train, y_train, batch_size=128, epochs=5, verbose=False, validation_split=.1)
loss, accuracy = model.evaluate(x_test, y_test, verbose=False)
Is there a way to convert the data created using the ImageDataGenerator into a format that would allow me to create a x_train, y_train, x_test, y_test data that's correctly formatted? Thanks