如何将训练图像数据集分为X_train和y_train?

时间:2019-07-12 02:50:50

标签: python keras

我正在尝试将训练图像数据集分为X_train和y_train,但我仍然不知道该怎么做。

train_path = '/content/drive/My Drive/CBD Robotics course/Assignment 08/fruits/fruits-360//Training'
test_path = '/content/drive/My Drive/CBD Robotics course/Assignment 08/fruits/fruits-360//Test'

from keras.preprocessing.image import ImageDataGenerator
# create a data generator
datagen = ImageDataGenerator()

# load and iterate training dataset
train_it = datagen.flow_from_directory(directory=train_path, target_size=(100, 100), color_mode="rgb",  class_mode='categorical', batch_size=64)
# load and iterate test dataset
test_it = datagen.flow_from_directory(directory=test_path, target_size=(100, 100), color_mode="rgb", class_mode='categorical', batch_size=64)

我希望我能从样本数据中得到类似示例代码的东西

(X_train, y_train), (X_test, y_test) = mnist.load_data()

如何将变量train_it和test_it转换为numpy数组并获取输入和标签部分?

0 个答案:

没有答案