我已经实现了具有以下架构的Keras模型:
使用此模型,我想在下一个时间步预测出租车需求。
当我在不对输入进行归一化的情况下训练模型时,一切正常,损耗降低。然后,当我对输入(需求)进行归一化时,模型也会成功编译并开始训练。但是损失并没有减少。在所有时期都保持不变。我真的不知道为什么吗?我确信我可以在代码的正确位置对输入进行标准化。可能是因为梯度消失了吗?
我的模特:
def generate_model(self):
# input for ConvLSTM
convlstm_input = Input(
shape=(self.lags, self.res, self.res, 1), name='Fahrten_pro_Zelle')
# first ConvLSTM-Layer
convlstm1 = ConvLSTM2D(filters=self.nb_filters, kernel_size=(self.k_size, self.k_size),
data_format='channels_last', padding='same',
return_sequences=True, name='ConvLSTM1')(convlstm_input)
# second ConvLSTM-Layer with doubled number of filters and doubled kernel_size
convlstm2 = ConvLSTM2D(filters=2 * self.nb_filters, kernel_size=(2 * self.k_size, 2 * self.k_size),
data_format='channels_last', padding='same', name='ConvLSTM2')(convlstm1)
mlp_input = Input(shape=(self.res, self.res, 37),
name='Metainformationen')
concat_layer = concatenate([convlstm2, mlp_input], name='Concatenate')
dense = Dense(100, activation='relu', name='FC1')(concat_layer)
dense = Dense(100, activation='relu', name='FC2')(dense)
dense = Dense(100, activation='relu', name='FC3')(dense)
main_output = Dense(1, activation='relu', name='Output')(dense)
# compile the model
model = Model(inputs=[convlstm_input, mlp_input],
outputs=[main_output])
opt = Adam(lr=self.lr)
model.compile(optimizer=opt, loss='mean_squared_error',
loss_weights=[1.])