[英]How to obtain same augmented images using ImageDataGenerator in keras or tensorflow?
[英]How ImageDataGenerator() calculate number of augmented images?
我很困惑。 我想知道 ImageDataGenerator() 在擬合訓練數據集時如何計算增強圖像的數量。
這是我用來理解數據增強的最簡單的代碼。 'train'目錄包含兩個目錄,每個目錄有10張圖片,一共20張圖片。
datagen = ImageDataGenerator(rotation_range=90,rescale=1./255)
iterator = datagen.flow_from_directory(
'train', # This is the source directory for training images
target_size=(150, 150),
batch_size=2,
save_to_dir='aug', #for saving augmented images
class_mode='binary')
history = model.fit(
iterator,
steps_per_epoch=10,
epochs=1,
verbose=1,
)
找到屬於 2 個類別的 20 張圖像。 訓練 10 步 10/10 [===============================] - 4s 384ms/步 - 損失:3.4463 - 准確度: 0.5000
我已將steps_per_epoch
設置為 10,因為 n_samples 為 20,batch size 為 2 (20/2=10)。 我不明白的是,“aug”目錄如何顯示 42 張圖像,而應該是 20 張,如何確定增強圖像的數量,以及 batch_size、steps_per_epochs、迭代意味着什么? 我很困惑!
請有人解釋一下
謝謝!
我很困惑。 我想知道 ImageDataGenerator() 在擬合訓練數據集時如何計算增強圖像的數量。
這是我用來理解數據增強的最簡單的代碼。 'train'目錄包含兩個目錄,每個目錄有10張圖片,一共20張圖片。
datagen = ImageDataGenerator(rotation_range=90,rescale=1./255)
iterator = datagen.flow_from_directory(
'train', # This is the source directory for training images
target_size=(150, 150),
batch_size=2,
save_to_dir='aug', #for saving augmented images
class_mode='binary')
history = model.fit(
iterator,
steps_per_epoch=10,
epochs=1,
verbose=1,
)
找到屬於 2 個類別的 20 張圖像。 訓練 10 步 10/10 [===============================] - 4s 384ms/步 - 損失:3.4463 - 准確度: 0.5000
我已將steps_per_epoch
設置為 10,因為 n_samples 為 20,batch size 為 2 (20/2=10)。 我不明白的是,“aug”目錄如何顯示 42 張圖像,而應該是 20 張,如何確定增強圖像的數量,以及 batch_size、steps_per_epochs、迭代意味着什么? 我很困惑!
請有人解釋一下
謝謝!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.