Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do I implement ssim for loss function in keras?

I need SSIM as a loss function in my network, but my network has 2 outputs. I need to use SSIM for first output and cross-entropy for the next. The loss function is a combination of them. However, I need to have a higher SSIM and lower cross-entropy, so I think the combination of them isn't true. Another problem is that I could not find an implementation of SSIM in keras.

Tensorflow has tf.image.ssim, but it accepts the image and I do not think I can use it in loss function, right? Could you please tell me what should I do? I am a beginner in keras and deep learning and I do not know how can I make SSIM as a custom loss function in keras.

like image 209
david Avatar asked Sep 12 '25 20:09

david


1 Answers

Have a look here for SSIM loss in Keras. You can write a custom loss function and create SSIM loss for one prediction and cross-entropy for another. You can return a weighted sum of the two losses as the final loss.

like image 139
Anakin Avatar answered Sep 15 '25 09:09

Anakin