private static Symbol MeanAbsoluteLogError(Symbol preds, Symbol labels) { Symbol first_log = OperatorSupply.Log(OperatorSupply.Clip(preds, float.Epsilon, 0) + 1); Symbol second_log = OperatorSupply.Log(OperatorSupply.Clip(labels, float.Epsilon, 0) + 1); Symbol loss = OperatorSupply.Mean(OperatorSupply.Square(first_log - second_log)); return(new Operator("MakeLoss").SetInput("data", loss).CreateSymbol("MeanAbsoluteLogError")); }
private static Symbol KullbackLeiblerDivergence(Symbol preds, Symbol labels) { Symbol y_true = OperatorSupply.Clip(labels, float.Epsilon, 1); Symbol y_pred = OperatorSupply.Clip(preds, float.Epsilon, 1); Symbol loss = OperatorSupply.Sum(y_true * OperatorSupply.Log(y_true / y_pred)); return(new Operator("MakeLoss").SetInput("data", loss).CreateSymbol("KullbackLeiblerDivergence")); }
private static Symbol MeanAbsolutePercentageError(Symbol preds, Symbol labels) { Symbol loss = OperatorSupply.Mean(OperatorSupply.Abs(labels - preds) / OperatorSupply.Clip(OperatorSupply.Abs(labels), float.Epsilon, 0)); return(new Operator("MakeLoss").SetInput("data", loss).CreateSymbol("MeanAbsolutePercentageError")); }