我已经写了下面的代码来加载训练和测试数据,我已经增强了训练数据集,但是我想把原始训练数据集和增强的训练数据集连接起来。我怎么做?
from tensorflow.keras.preprocessing.image import ImageDataGenerator
train_datagen = ImageDataGenerator(
rescale=1./255,
rotation_range=5,
zoom_range = 0.1,
width_shift_range=0.1,
height_shift_range=0.1,
validation_split=0.2
)
test_datagen = ImageDataGenerator(rescale=1./255)
train_dir = 'train_separated'
test_dir = 'test_separated'
batch_size = 128
img_height = 100
img_width = 100
num_classes = 10
# load train and test data
train_data = train_datagen.flow_from_directory(
train_dir,
target_size=(img_height, img_width),
batch_size=batch_size,
class_mode='categorical',
subset='training')
# after that I have train_data that was augmented, but how to concatenete new augmented data with original train data?
val_data = train_datagen.flow_from_directory(
train_dir,
target_size=(img_height, img_width),
batch_size=batch_size,
class_mode='categorical',
subset='validation')
test_data = test_datagen.flow_from_directory(
test_dir,
target_size=(img_height, img_width),
batch_size=batch_size,
class_mode='categorical')
我希望我的训练数据将包含增强的训练数据和原始数据。
1条答案
按热度按时间j8ag8udp1#
我发现了一个方法。在这里我给你举一个例子: