function X = internal_fullyconnect(X, W, B, batchDims)
% This function is undocumented and will change in a future release.

%   X = internal_fullyconnect(X, W, B, batchDim)
%   Compute the affine transformation Y = W*X + B.
%   The input X is first reshaped to a 2D matrix with inputSize x
%   batchSize dimensions.
%
%   Inputs:
%     X               Feature data.
%                     numeric array
%     W               Weights. 
%                     numeric array 
%     B               Bias. outputSize x 1 array.
%                     numeric array 
%     batchDim        Observations dimension.
%                     double
%  
%   Outputs:
%     Y               Output classes. outputSize x batchSize array.
%                     numeric array

%   Copyright 2019 The MathWorks, Inc.

% Flatten the data
X = reshape(X, [], prod(size(X, batchDims)));

% Linear matrix multiplication
X = W*X + B;

end




