image and label我有兩個分別包含數(shù)據(jù)的 numpy 變量。500 labeled image每種形狀都有image is 240 x 240.import numpy as np
images = np.random.randint(4, size=(500,240,240))
labels = np.random.rand(500,240,240)如何使用 Keras 生成器進行模型訓(xùn)練?在此先感謝您的幫助。
1 回答

慕容3067478
TA貢獻1773條經(jīng)驗 獲得超3個贊
如果您愿意對圖像進行一些小的更改,則可以輕松完成此操作?;旧?,您需要向(通道維度)添加一維images。
import numpy as np
import tensorflow as tf
images = np.expand_dims(np.random.randint(4, size=(500,240,240)),-1)
labels = np.random.rand(500,240,240)
gen = tf.keras.preprocessing.image.ImageDataGenerator()
res = gen.flow(images, labels)
x, y = next(res)
您可以通過創(chuàng)建另一個生成器生成 Keras 生成器的數(shù)據(jù)并刪除該維度來進行后處理并刪除該維度。
添加回答
舉報
0/150
提交
取消