%% Mean Absolute Error Loss
% Create an array of predictions for 12 observations over 10 responses.

numResponses = 10;
numObservations = 12;

Y = rand(numResponses,numObservations);
dlY = dlarray(Y,'CB');

% View the size and format of the predictions.

size(dlY)
dims(dlY)

% Create an array of random targets.

targets = rand(numResponses,numObservations);

% View the size of the targets.

size(targets)

% Compute the mean absolute error (MAE) loss between the predictions and the targets using the l1loss function.

loss = l1loss(dlY,targets)

% Copyright 2021 The MathWorks, Inc.