Main Content

mae

Mean absolute error performance function

Description

Tip

To use mean absolute error with deep learning, use the trainnet function and set the loss function to "mae", or use the l1loss function for dlarray objects.

perf = mae(E,Y,X) takes a matrix or cell array of error vectors, E, and optionally a matrix or cell array of output vectors, Y, a vector of all weight and bias values, X, and returns network performance as the mean of absolute errors, perf.

example

dPerf_dx = mae('dx',E,Y,X,perf) returns the derivative of perf with respect to X.

info = mae('code') returns useful information for each code character vector:

  • mae('name') returns the name of this function.

  • mae('pnames') returns the names of the training parameters.

  • mae('pdefaults') returns the default function parameters.

Examples

collapse all

This example shows how to calculate the network performance as the mean of absolute errors.

Create and configure a perceptron to have one input and one neuron:

net = perceptron;
net = configure(net,0,0);

The network is given a batch of inputs P. The error is calculated by subtracting the output A from target T. Then the mean absolute error is calculated.

p = [-10 -5 0 5 10];
t = [0 0 1 1 1];
y = net(p)
e = t-y
perf = mae(e)

Note that mae can be called with only one argument because the other arguments are ignored. mae supports those arguments to conform to the standard performance function argument list.

Input Arguments

collapse all

Errors, specified as a vector, a matrix, or a cell array.

Network outputs, specified as a vector, a matrix, or a cell array.

Weight and bias values, specified as a vector.

Output Arguments

collapse all

Network performance as the mean of absolute errors, returned as a scalar.

Derivative of perf with respect to X, returned as a scalar.

More About

collapse all

Network Use

You can create a standard network that uses mae with perceptron.

To prepare a custom network to be trained with mae, set net.performFcn to 'mae'. This automatically sets net.performParam to the empty matrix [], because mae has no performance parameters.

In either case, calling train or adapt, results in mae being used to calculate performance.

Version History

Introduced before R2006a

See Also

|