Hi CNTK team,
First, thanks for building this awesome ML library.
We're trying to build a regression model and it's working great for big values, but badly for the smaller ones.
We think the problem is that we use SquareError as the loss / evalError function, and we would like to use Mean Absolute Percentage Error (https://en.wikipedia.org/wiki/Mean_absolute_percentage_error) instead.
The C# API provides only three Error functions: (ClassificationError, EditDistanceError and SquaredError).
It looks like we can implement our own (https://docs.microsoft.com/en-us/cognitive-toolkit/Reduction-Operations) but we have problems with the mandatory Axis parameter in C#:
```C#
public static Function MeanAbsoluteError(Variable prediction, Variable targets)
{
var absolute = CNTKLib.Abs(CNTKLib.Minus(targets, prediction));
return CNTKLib.ReduceMean(absolute, /*axis required here*/);
}
public static Function MeanAbsolutePercentageError(Variable prediction, Variable targets)
{
var absolute = CNTKLib.Abs(CNTKLib.Minus(targets, prediction));
var absolutePercentage = CNTKLib.ElementDivide(absolute, targets);
return CNTKLib.ReduceMean(absolutePercentage, /*axis required here*/);
}
```
What is the value that should be provided there?
Thanks in advance.
Hi all ,
the following should do the trick:
```C#
public static Function MeanAbsoluteError(Variable prediction, Variable targets)
{
var absolute = CNTKLib.Abs(CNTKLib.Minus(targets, prediction));
return CNTKLib.ReduceMean(absolute, new Axis(-1));
}
public static Function MeanAbsolutePercentageError(Variable prediction, Variable targets)
{
var absolute = CNTKLib.Abs(CNTKLib.Minus(targets, prediction));
var absolutePercentage = CNTKLib.ElementDivide(absolute, targets);
return CNTKLib.ReduceMean(absolutePercentage, new Axis(-1));
}
```
It would be great, if common loss/error functions like MAP, MAPE, etc would be exposed by the CNTK C# bindings in a future version.
What exactly are actually the semantics of Axes and their indices? The wikis/comments explanations vary a little bit and are very short.
Most helpful comment
Hi all ,
the following should do the trick:
```C#
public static Function MeanAbsoluteError(Variable prediction, Variable targets)
{
var absolute = CNTKLib.Abs(CNTKLib.Minus(targets, prediction));
```
It would be great, if common loss/error functions like MAP, MAPE, etc would be exposed by the CNTK C# bindings in a future version.