MATLAB Answers

1

custom loss function for DNN training

Asked by Pratheek on 16 May 2019
Latest activity Commented on by ghali ahmed on 17 Oct 2019 at 18:18
how can i write a custom loss fucntion for DNN training. I want to try reconstruction loss

  0 Comments

Sign in to comment.

1 Answer

Answer by Shounak Mitra on 17 May 2019

You can create custom layers and define custom loss functions for output layers.
The output layer uses two functions to compute the loss and the derivatives: forwardLoss and backwardLoss. The forwardLoss function computes the loss L. The backwardLoss function computes the derivatives of the loss with respect to the predictions.
For eg., to write a weighted cross entropy classification loss, try running this in the MATLAB command window
>> edit(fullfile(matlabroot,'examples','deeplearning_shared','main','weightedClassificationLayer.m'))
Hope this helps

  1 Comment

ghali ahmed on 17 Oct 2019 at 18:18
hi!
is there more details for a real implementation :)
thank's

Sign in to comment.