2

I plan to write a function which will output the derivative of a hinge loss w.r.t the ground truth. I consider the function as following from this link whereas Y(the first parameter)is the prediction and Y. (the second parameter) is the ground truth.

During calculating backward loss, what I understand is, I need to calculate the derivative of the above loss w.r.t the second parameter, right? In that case, will the code be like following:

function dLdX = backwardLoss1( this, Y, T )
            % backwardLoss    Back propagate the derivative of the loss
            % function
            %
            % Syntax:
            %   dLdX = layer.backwardLoss( Y, T );
            %
            % Image Inputs:
            %   Y   Predictions made by network, 1-by-1-by-numClasses-by-numObs
            %   T   Targets (actual values), 1-by-1-by-numClasses-by-numObs
            %
            % Vector Inputs:
            %   Y   Predictions made by network,  numClasses-by-numObs-by-seqLength
            %   T   Targets (actual values),  numClasses-by-numObs-by-seqLength
          if(Y*T<1)
                dLdX=-T/size(Y);
           else
                dLdX=0;
            end         
        end

But following this link, it's displaying the calculation of the derivative w.r.t the parameters which make me confuse that should I need to output the loss w.rt the weights as well as w.r.t to the ground truth?

Besides, if I consider this link, where @David Dale has explained a similar question, I am confused that am I following the same thing or not?

I am looking for your suggestions in this regard. thanks,

Basu S
  • 21

0 Answers0