Package org.nd4j.autodiff.loss
Enum LossReduce
- java.lang.Object
-
- java.lang.Enum<LossReduce>
-
- org.nd4j.autodiff.loss.LossReduce
-
- All Implemented Interfaces:
Serializable,Comparable<LossReduce>
public enum LossReduce extends Enum<LossReduce>
-
-
Enum Constant Summary
Enum Constants Enum Constant Description MEAN_BY_NONZERO_WEIGHT_COUNTWeighted mean: sum(weights * perOutputLoss) / count(weights != 0)
Example: 2d input, mean squared error loss.
Output: squared_error_per_ex = weights * squaredDifference(predictions,labels)
output = sum(squared_error_per_ex) / count(weights != 0)
NOTE: if weights array is not provided, then weights default to scalar 1.0 and hence MEAN_BY_NONZERO_WEIGHT_COUNT is equivalent to MEAN_BY_WEIGHTMEAN_BY_WEIGHTWeighted mean: sum(weights * perOutputLoss) / sum(weights) - gives a single scalar output
Example: 2d input, mean squared error
Output: squared_error_per_ex = weights * squaredDifference(predictions,labels)
output = sum(squared_error_per_ex) / sum(weights)
NOTE: if weights array is not provided, then weights default to 1.0 for all entries - and hence MEAN_BY_WEIGHT is equivalent to MEAN_BY_NONZERO_WEIGHT_COUNTNONENo reduction.SUMWeigted sum across all loss values, returning a scalar.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static LossReducevalueOf(String name)Returns the enum constant of this type with the specified name.static LossReduce[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
NONE
public static final LossReduce NONE
No reduction. In most cases, output is the same shape as the predictions/labels.
Weights (if any) are applied
Example Input: 2d input array with mean squared error loss.
Example Output: squaredDifference(predictions,labels), with same shape as input/labels
-
SUM
public static final LossReduce SUM
Weigted sum across all loss values, returning a scalar.
-
MEAN_BY_WEIGHT
public static final LossReduce MEAN_BY_WEIGHT
Weighted mean: sum(weights * perOutputLoss) / sum(weights) - gives a single scalar output
Example: 2d input, mean squared error
Output: squared_error_per_ex = weights * squaredDifference(predictions,labels)
output = sum(squared_error_per_ex) / sum(weights)
NOTE: if weights array is not provided, then weights default to 1.0 for all entries - and hence MEAN_BY_WEIGHT is equivalent to MEAN_BY_NONZERO_WEIGHT_COUNT
-
MEAN_BY_NONZERO_WEIGHT_COUNT
public static final LossReduce MEAN_BY_NONZERO_WEIGHT_COUNT
Weighted mean: sum(weights * perOutputLoss) / count(weights != 0)
Example: 2d input, mean squared error loss.
Output: squared_error_per_ex = weights * squaredDifference(predictions,labels)
output = sum(squared_error_per_ex) / count(weights != 0)
NOTE: if weights array is not provided, then weights default to scalar 1.0 and hence MEAN_BY_NONZERO_WEIGHT_COUNT is equivalent to MEAN_BY_WEIGHT
-
-
Method Detail
-
values
public static LossReduce[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (LossReduce c : LossReduce.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static LossReduce valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
-