I am training a time series model using sequential model the code is as below:
model <- keras_model_sequential() %>%
layer_lstm(units = 10,
batch_input_shape = c(1, pq, 1),
stateful = TRUE) %>%
layer_dense(units = 1, activation = "relu")
model %>%
compile(loss = 'mse', optimizer = optimizer_adam(learning_rate = 0.00001), metrics = 'mae')
summary(model)
model %>% fit(
x = X_tr,
y = Y_tr,
batch_size = 1,
epochs = 30,
verbose = 1,
shuffle = FALSE
)
When I try changing different epoch (30, 50, 100), it seems to me that the loss function stays constant afer epoch 3. I know that keras has function callback early stopping so that we can stop training when the loss function does not decrease anymore. I tried to include this argument in the fit() as below
model %>% fit(
x = X_tr,
y = Y_tr,
batch_size = 1,
epochs = 30,
verbose = 1,
shuffle = FALSE,
callbacks = list (callback_early_stopping(monitor = "loss", patience = 5,
verbose = 0, mode = "min"))
)
My expectation is that I can see any message that can tell me that the training is stopped at epoch...with loss = ...and mae = ...., for example, or at least any notification to let me know that the training is stopped where. So I am not sure if this is the way how to do it, and is there any missing because when I use the updated line code as above in R, nothing happens, the model runs till the end of epoch 30 as normal. Please help if you have any idea.