To train the model, we use images with noise stored in trainn as input and images without noise stored in trainx as output. The code that's used to fit the model is as follows:
# Fit model
model_two <- ae_model %>% fit(trainn,
trainx,
epochs = 100,
shuffle = TRUE,
batch_size = 128,
validation_data = list(testn,testx))
Here, we also use testn and testx to monitor validation errors. We will run 100 epochs with a batch size of 128. After network training is completed, we obtain the loss values for the train and test data using the following code:
# Loss for train data
ae_model %>% evaluate(trainn, trainx)
loss
0.07431865
# Loss for test data
ae_model %>% evaluate(testn, testx)
loss
0.07391542
The loss for the training and test data is 0.0743 and 0.0739, respectively. The closeness of the two numbers indicates the lack of an overfitting problem.