I am using 2 BatchNormalization
layers in Keras for a huge dataset that does not fit into memory. I can train with normalized values, but since I want to do a regression, I need to reverse or undo the effects of the normalization, that is, after I do
prediction = model.predict(my_test)
I obtain values that are affected by the 2 BatchNormalizations
, and I want to apply to prediction
a function to show the values in their natural scale. How can I do this in Keras? Note that I have 2 layers of BatchNormalization
.
(I know how to do it when the dataset fits into memory and I normalize it before the training without using BatchNormalization
, and then de-normalize it, but in this case I am confused). Thx.
Addendum: By @Romain's suggestion: full model. Inspired by https://medium.com/@rajin250/precipitation-prediction-using-convlstm-deep-neural-network-b9e9b617b436 I want to predict rainfall based in previous rainfall images for a 150x150 points of a grid area, so I have data from 0 to unbounded values,
model = Sequential()
model.add(ConvLSTM2D(filters=32, kernel_size=(5, 5),
input_shape=(None, 150, 150, 1), padding='same',
return_sequences=True,
activation="tanh", recurrent_activation='hard_sigmoid',
kernel_initializer='glorot_uniform',
unit_forget_bias=True,
dropout=0.2, recurrent_dropout=0.2))
model.add(BatchNormalization())
model.add(ConvLSTM2D(filters=32, kernel_size=(2, 2), padding='same',
return_sequences=False,
activation="tanh", recurrent_activation='hard_sigmoid',
kernel_initializer='glorot_uniform',
unit_forget_bias=True,
dropout=0.2, recurrent_dropout=0.2))
model.add(BatchNormalization())
model.add(Conv2D(filters=1, kernel_size=(1, 1),
#activation="sigmoid",
padding='same', data_format='channels_last'))
model.compile(optimizer="adam", loss="mse")
I have made explicit that the activation is commented since the sigmoid forces my values to be between 0 and 1. The training is working but the values I obtain are very small, far from reality, so my thought was that I needed to de-normalize somehow...