Class BinaryCrossEntropyLoss
java.lang.Object
deepnetts.net.loss.BinaryCrossEntropyLoss
- All Implemented Interfaces:
LossFunction, Serializable
Cross Entropy Loss is a loss function used for binary classification tasks (two classes, single output which represents probability ).
It should be used in combination with sigmoid output activation function.
The formula:
E = (1/n) * -SUM( t * ln(y) + (1-t) * ln(1-y) )
where t is target, and y actual output
Bishop, C. pg. 231, eq. 6.120
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddPatternError(TensorBase predictedOutput, TensorBase targetOutput) Calculates error for given actual and target patterns and adds that error to total error.voidaddRegularizationSum(float regSum) Adds specified regularization sum to total loss.floatfloatgetTotal()Returns the total error calculated by this loss function.voidreset()Resets the total error and pattern counter.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface LossFunction
valueFor
-
Constructor Details
-
BinaryCrossEntropyLoss
-
-
Method Details
-
addPatternError
Calculates error for given actual and target patterns and adds that error to total error. Returns output error vector for specified actual and target outputs.- Specified by:
addPatternErrorin interfaceLossFunction- Parameters:
predictedOutput- predicted output of a neural networktargetOutput- target output of a neural network- Returns:
- error vector for specified predicted and target outputs
-
getPatternLoss
public float getPatternLoss()- Specified by:
getPatternLossin interfaceLossFunction
-
addRegularizationSum
public void addRegularizationSum(float regSum) Description copied from interface:LossFunctionAdds specified regularization sum to total loss.- Specified by:
addRegularizationSumin interfaceLossFunction- Parameters:
regSum- regularization sum
-
getTotal
public float getTotal()Description copied from interface:LossFunctionReturns the total error calculated by this loss function.- Specified by:
getTotalin interfaceLossFunction- Returns:
- total error calculated by this loss function
-
reset
public void reset()Description copied from interface:LossFunctionResets the total error and pattern counter.- Specified by:
resetin interfaceLossFunction
-