![](/img/trans.png)
[英]How to normalize LSTM input data in Keras with BatchNormalization
[英]how to normalize my image data in Tensorflow Keras
如前所述,我正在嘗試在訓練我的 model 之前標准化我的數據集。 我以前使用tf.keras.preprocessing.image.ImageDataGenerator
來執行此操作。
train_data = tf.cast(train_data, tf.float32)
train_gen = ImageDataGenerator(
featurewise_center=True,
featurewise_std_normalization=True
)
train_gen.fit(train_data)
train_generator = train_gen.flow(train_data, train_labels,
batch_size=batch_size,
shuffle=True)
model.fit(train_generator, epochs=base_epochs)
但是,我不得不放棄它,因為我使用自定義層實現了復雜的損失 function。 因此,需要將數據和標簽分別作為輸入發送到 model。 Tensorflow Keras 中是否提供任何其他 function 來標准化我的樣本?
def standardize(image_data):
image_data -= np.mean(image_data, axis=0)
image_data /= np.std(image_data, axis=0)
return image_data
這是解決問題的簡單方法。 自己預處理數據。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.