What is the purpose of the add_loss function in Keras?

I’ll try to answer the original question of why model.add_loss() is being used instead of specifying a custom loss function to model.compile(loss=…). All loss functions in Keras always take two parameters y_true and y_pred. Have a look at the definition of the various standard loss functions available in Keras, they all have these two parameters. … Read more

ValueError: Error when checking target: expected model_2 to have shape (None, 252, 252, 1) but got array with shape (300, 128, 128, 3)

It’s a simple incompatibility between the output shape of the decoder and the shape of your training data. (Target means output). I see you’ve got 2 MaxPoolings (dividing your image size by 4), and three upsamplings (multiplying the decoder’s input by 8). The final output of the autoencoder is too big and doesn’t match your … Read more