faceswap icon indicating copy to clipboard operation
faceswap copied to clipboard

Why use mean_absolute_error as loss function instead of mean_squared_error?

Open BeatHarness opened this issue 8 years ago • 9 comments

I've always been taught MSE would be the standard loss function to pick. On the other hand, I don't know what most of the other Keras loss functions do exactly either.

Can somebody explain the reasoning for choosing MAE?

And while I'm at it, can somebody explain (or point me to some reading material) why the Adam optimizer is chosen over any of the others?

BeatHarness avatar Feb 04 '18 23:02 BeatHarness

I have very limited knowdge about autoencoders, but I’ve seen both L1 and L2 loss benn used in papers (as the loss func. to ground truth image). I think its somehow hurustic and empirical. In fact, I’ve tried both losses in this project but didn’t find much difference in terms of output quality.

shaoanlu avatar Feb 05 '18 09:02 shaoanlu

@IUsedToBeAPygmy im experimenting with using the Nadam optimizer due to this paper:

https://openreview.net/pdf?id=OM0jvwB8jIp57ZJjtNEZ

gdunstone avatar Feb 05 '18 16:02 gdunstone

image

Quick test.

gdunstone avatar Feb 05 '18 16:02 gdunstone

@gdunstone - I've just tried to replace the used Adam with Keras' standard Nadam, but all I get is completely red images so apparently it's not just a drop-in replacement. Did you get it to work and if so, how?

BeatHarness avatar Feb 06 '18 08:02 BeatHarness

Also, I've created a model that implements the loss function as a mix of SSIM and L2 and uses PELU instead of LeakyReLu which seems to work rather well (have only been training shortly so I'll might eat those words later). If I find it does and people want I can put in a pull request later.

http://research.nvidia.com/sites/default/files/pubs/2017-03_Loss-Functions-for/NN_ImgProc.pdf

BeatHarness avatar Feb 06 '18 08:02 BeatHarness

@IUsedToBeAPygmy Thanks! Can you work it as a plugin similar to how GAN is being used?

I literally did a drop in replacement of Adam with Nadam, and the preview output while I was gathering the above data looked totally fine.

gdunstone avatar Feb 06 '18 11:02 gdunstone

I'm using the SSIM from keras.contrib and mix its result with the result of a normal loss function like mean_absolute_error (using a very small factor for the SSIM).

https://github.com/keras-team/keras-contrib/blob/master/keras_contrib/losses/dssim.py

Keras.contrib also supplies alternative advanced activation functions like PELU.

BeatHarness avatar Feb 07 '18 09:02 BeatHarness

Can you get us some of those sweet sweet numbers? Or hook us up with a hit of graphs? :stuck_out_tongue:

gdunstone avatar Feb 07 '18 16:02 gdunstone

I'm going to hook you up with the code soon so you can make your own graphs :)

BeatHarness avatar Feb 08 '18 15:02 BeatHarness