Last active
August 27, 2019 23:18
-
-
Save GeorgeSeif/03ee25ee927f6524fbb74904d6eeb3e4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import math | |
| from keras import backend as K | |
| # Define our custom metric | |
| def PSNR(y_true, y_pred): | |
| max_pixel = 1.0 | |
| return 10.0 * math.log10((max_pixel ** 2) / (K.mean(K.square(y_pred - y_true)))) | |
| # Define our custom loss function | |
| def charbonnier(y_true, y_pred): | |
| epsilon = 1e-3 | |
| error = y_true - y_pred | |
| p = K.sqrt(K.square(error) + K.square(epsilon)) | |
| return K.mean(p) | |
| # Compile our model | |
| adam = Adam(lr=0.0001) | |
| model.compile(loss=[charbonnier], metrics=[PSNR], optimizer=adam) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment