2
I am developing a machine Learning model using the Keras library and realize that the available loss functions are not giving the best results in my test suite.
I’m using an Unet architecture, where I enter an image (16,16,3) and the network also generates an image (16,16,3) (auto-Ncoder). I realized that perhaps a way to improve the model would be if I used a loss function that compares pixel to pixel in the image gradients (Laplaciano) between the network output and the Ground Truth set. However, I didn’t find any tutorial that could handle this type of application because it would need to use opencv’s Laplacian function on each network output image.
The loss function would be something like this:
def laplacian_loss(y_true, y_pred):
# y_true already is the calculated gradients, only needs to compute on the y_pred
# calculates the gradients for each predicted image
y_pred_lap = []
for img in y_pred:
laplacian = cv2.Laplacian( np.float64(img), cv2.CV_64F )
y_pred_lap.append( laplacian )
y_pred_lap = np.array(y_pred_lap)
# mean squared error, according to keras losses documentation
return K.mean(K.square(y_pred_lap - y_true), axis=-1)
Someone has done something similar for the loss calculation?
Translate your Question to English.
– Boneco Sinforoso
I put it in the wrong place, I just translated it.
– Lucas Kirsten