The code for obtaining the loss, accuracy, and confusion matrix based on the training data is as follows:
# Loss and accuracymodel %>% evaluate(trainx, trainy)$loss[1] 3.335224$acc[1] 0.8455# Confusion matrixpred <- model %>% predict_classes(trainx)table(Predicted=pred, Actual=data$train$y[1:2000,]) ActualPredicted 0 1 2 3 4 5 6 7 8 9 0 182 2 8 2 9 4 1 2 10 5 1 1 176 3 5 6 5 2 3 4 7 2 1 0 167 4 3 4 3 2 0 1 3 0 0 0 157 2 1 1 2 1 0 4 2 1 5 6 167 4 2 1 0 0 5 2 0 4 4 3 149 3 4 4 3 6 1 1 3 6 5 2 173 5 0 0 7 3 2 4 2 4 3 9 166 0 1 8 10 1 7 1 6 4 2 2 173 5 9 0 8 2 8 9 7 11 12 11 181
Here, we can see that the loss and accuracy values for the training data are 3.335 and 0.846, respectively. The confusion matrix ...