Ejemplo n.º 1
0
# model.add(Dense(1))
# model.compile(loss='mean_squared_error', optimizer='adam')
# for i in range(nb_epoch):
#    model.fit(X_train, y_train, epochs=1, batch_size=batch_size, verbose=0, shuffle=False)
#    model.reset_states()

inputs_1_mae = Input(batch_shape=(batch_size, timesteps, 1))
lstm_1_mae = LSTM(10, stateful=True, return_sequences=True)(inputs_1_mae)
lstm_2_mae = LSTM(10, stateful=True, return_sequences=True)(lstm_1_mae)

output_1_mae = Dense(units=1)(lstm_2_mae)

regressor_mae = Model(inputs=inputs_1_mae, outputs=output_1_mae)

regressor_mae.compile(optimizer='adam', loss='mae')
regressor_mae.summary()

epochs = 2
for i in range(epochs):
    print("Epoch: " + str(i))
    regressor_mae.fit(X_train,
                      y_train,
                      shuffle=False,
                      epochs=1,
                      batch_size=batch_size)
    regressor_mae.reset_states()

test_length = data_misc.get_test_length(dataset=raw_values,
                                        batch_size=batch_size,
                                        upper_train=upper_train,
                                        timesteps=timesteps)