To prepare our data for the steps that follow, we'll reshape trainx so that its dimensions are 5,421 x 28 x 28 x 1, as shown in the following code:
# Reshaping data
trainx <- array_reshape(trainx, c(nrow(trainx), 28, 28, 1))
trainx <- trainx / 255
Here, we also divide the values in trainx by 255 to obtain a range of values between 0 and 1. With the data processed in the required format, we can move on and develop the architecture for the generator network.