function X = internal_catcrossentropy(X, T, observationDim)
% This function is undocumented and will change in a future release.

% internal_crossentropy    Return the categorical cross-entropy between
% estimates X and true responses T averaged by the number of observations
%
% Syntax:
%   Y = internal_catcrossentropy(X, T, observationDim, hasIndependentTargetCategories);
%
% Inputs (image):
%   X              Predictions made by network
%   T              Targets (actual values)
%   observationDim Index of the observations dimension

%   Copyright 2019-2020 The MathWorks, Inc.

N = size(X, observationDim);
X = nnet.internal.cnn.util.boundAwayFromZero(X);
X = -sum(T.*log(X),'all')/N; 

end
