Cost function and cost gradient function for a convolutional autoencoder.