简体   繁体   中英

How can I apply BatchNormalization to an Input for a Keras LSTM?

I have:

    model = Sequential()
    model.add(LSTM(32, input_shape=(
        SEQ_LENGTH, VECTOR_SIZE), return_sequences=True))
    model.add(TimeDistributed(Dense(VECTOR_SIZE, activation='relu')))

    adam_optimizer = optimizers.Adam(
        learning_rate=0.001, beta_1=0.9, beta_2=0.999, amsgrad=False)
    model.compile(loss='mean_squared_error',
                  optimizer=adam_optimizer)

The input and output of my model are both (100, 129) .

model.add(BatchNormalization(center=True, scale=True, beta_regularizer=regularizers.l2(0.01),
                                 gamma_regularizer=regularizers.l2(0.01),
                                 beta_constraint='max_norm', gamma_constraint='max_norm',
                                 input_shape=(x, y)))

It's just a layer that you add into your model

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM