Next, we simply compile our network with the same optimizer and loss function that we chose for the deep feed-forward network and initiate the training session by calling .fit() on the model object. Do note that we only train this model for 50 epochs and perform weight updates in batches of 128 images at a time. This approach turns out to be computationally faster, allowing us to train the model for a fraction of the time that was taken to train the feed-forward model. Let's see whether the chosen trade-off between training time and accuracy works out in our favor for this specific use case:
autoencoder.compile(optimizer='adam', loss='mse')
autoencoder.fit(x_train, x_train, epochs=50, batch_size=20,
shuffle=True, verbose=1)
Epoch 1/50
875/875 [==============================] - 7s 8ms/step - loss: 0.0462
Epoch...