dlarray
Supportdlarray
SupportThese tables list and briefly describe the Deep Learning Toolbox™ functions that operate on dlarray
objects.
Function  Description 

avgpool  The average pooling operation performs downsampling by dividing the input into pooling regions and computing the average value of each region. 
batchnorm  The batch normalization operation normalizes each input channel
across a minibatch. To speed up training of convolutional neural networks and reduce the
sensitivity to network initialization, use batch normalization between convolution and nonlinear
operations such as relu . 
crossentropy  The crossentropy operation computes the crossentropy loss between network predictions and target values for singlelabel and multilabel classification tasks. 
crosschannelnorm  The crosschannel normalization operation uses local responses
in different channels to normalize each activation. Crosschannel normalization typically
follows a relu operation.
Crosschannel normalization is also known as local response normalization. 
dlconv  The convolution operation applies sliding filters to the input data. Use 1D and 2D filters with ungrouped or grouped convolutions and 3D filters with ungrouped convolutions. 
dltranspconv  The transposed convolution operation upsamples feature maps. 
embed  The embed operation converts numeric indices to numeric vectors, where the indices correspond to discrete data. Use embeddings to map discrete data such as categorical values or words to numeric vectors. 
fullyconnect  The fully connect operation multiplies the input by a weight matrix and then adds a bias vector. 
groupnorm  The group normalization operation divides the channels of the input data into groups and normalizes the activations across each group. To speed up training of convolutional neural networks and reduce the sensitivity to network initialization, use group normalization between convolution and nonlinear operations such as relu . You can perform instance normalization and layer normalization by setting the appropriate number of groups. 
gru  The gated recurrent unit (GRU) operation allows a network to learn dependencies between time steps in time series and sequence data. 
leakyrelu  The leaky rectified linear unit (ReLU) activation operation performs a nonlinear threshold operation, where any input value less than zero is multiplied by a fixed scale factor. 
lstm  The long shortterm memory (LSTM) operation allows a network to learn longterm dependencies between time steps in time series and sequence data. 
maxpool  The maximum pooling operation performs downsampling by dividing the input into pooling regions and computing the maximum value of each region. 
maxunpool  The maximum unpooling operation unpools the output of a maximum pooling operation by upsampling and padding with zeros. 
mse  The half mean squared error operation computes the half mean squared error loss between network predictions and target values for regression tasks. 
relu  The rectified linear unit (ReLU) activation operation performs a nonlinear threshold operation, where any input value less than zero is set to zero. 
onehotdecode  The onehot decode operation decodes probability vectors, such as the output of a classification network, into classification labels. The input 
sigmoid  The sigmoid activation operation applies the sigmoid function to the input data. 
softmax  The softmax activation operation applies the softmax function to the channel dimension of the input data. 
dlarray
Specific FunctionsFunction  Description 

dims  This function returns the data format of a dlarray . 
dlfeval  This function evaluates a
dlarray function using automatic
differentiation. 
dlgradient  This function computes gradients using automatic differentiation. 
dlresize (Image Processing Toolbox)  This function resizes the spatial dimensions
of a dlarray . 
extractdata  This function extracts the data from a dlarray . 
finddim  This function finds the indices of dlarray dimensions with a given dimension
label. 
stripdims  This function removes the data format from a dlarray . 
dlarray
SupportMany MATLAB^{®} functions operate on dlarray
objects. These tables list the
usage notes and limitations for these functions when you use dlarray
arguments.
Function  Notes and Limitations 

abs  The output 
acos 

acosh 

acot  The output 
acsc 

asec  
asin 

asinh  The output 
atan  
atan2  
atanh 

cos  The output 
cosh  
cot  
csc  
exp  
log 

sec 
The output 
sign  
sin  
sinh  
sqrt 

tan  The output 
tanh  
uminus ,
  
uplus ,
+ 
Function  Notes and Limitations 

minus ,
  If the two 
plus ,
+  
power ,
.^ 

rdivide ,
./  If the two 
times ,
.* 
Function  Notes and Limitations 

mean 

prod 

sum 
Function  Notes and Limitations 

ceil  The output 
eps 

fix  The output 
floor  The output 
max 

min  
rescale 

round 

Function  Notes and Limitations 

colon ,
: 

interp1 

mrdivide ,
/  The second 
mtimes ,
*  One input can be a formatted 
pagemtimes  One input can be a formatted 
Function  Notes and Limitations 

all 
The output 
and ,
&  If the two 
any 
The output 
eq ,
==  If the two 
ge ,
>=  
gt ,
>  
le ,
<=  
lt ,
<  
ne ,
~=  
not ,
~ 
The output 
or ,
  If the two 
xor 
Function  Notes and Limitations 

reshape  The output 
squeeze  Twodimensional 
Function  Notes and Limitations 

ctranspose ,
'  If the input 
permute  If the input 
transpose ,
.'  If the input 
Function  Notes and Limitations 

cast 

double  The output is a 
gather (Parallel Computing Toolbox) 

gpuArray (Parallel Computing Toolbox) 

logical  The output is a dlarray that contains data of type
logical . 
single  The output is a dlarray that contains data of type
single . 
Function  Notes and Limitations 

isequal 

isequaln 

Function  Notes and Limitations 

isdlarray
 N/A 
isfinite  The software
applies the function to the underlying data of an input

isfloat  
isgpuarray (Parallel Computing Toolbox)  
isinf  
islogical  
isnan  
isnumeric  
isreal  Because 
isUnderlyingType  N/A 
mustBeUnderlyingType  
underlyingType 
Function  Notes and Limitations 

iscolumn  This function returns true for a
dlarray that is a column vector, where each
dimension except the first is a singleton. For example, a 3by1by1
dlarray is a column vector. 
ismatrix  This function returns true for
dlarray objects with only two dimensions and for
dlarray objects where each dimension except the
first two is a singleton. For example, a 3by4by1
dlarray is a matrix. 
isrow  This function returns true for a
dlarray that is a row vector, where each dimension
except the second is a singleton. For example, a 1by3by1
dlarray is a row vector. 
isscalar  N/A 
isvector  This function returns true for a
dlarray that is a row vector or column vector. Note
that isvector does not consider a 1by1by3
dlarray to be a vector. 
length  N/A 
ndims  If the input 
numel  N/A 
size  If the input 
Some functions use implicit expansion to combine two
formatted dlarray
inputs. The function introduces labeled singleton
dimensions (dimensions of size 1) into the inputs, as necessary, to make their formats
match. The function inserts singleton dimensions at the end of each block of dimensions
with the same label.
To see an example of this behavior, enter the following code.
X = ones(2,3,2); dlX = dlarray(X,'SCB') Y = 1:3; dlY = dlarray(Y,'C') dlZ = dlX.*dlY
dlX = 2(S) × 3(C) × 2(B) dlarray (:,:,1) = 1 1 1 1 1 1 (:,:,2) = 1 1 1 1 1 1 dlY = 3(C) × 1(U) dlarray 1 2 3 dlZ = 2(S) × 3(C) × 2(B) dlarray (:,:,1) = 1 2 3 1 2 3 (:,:,2) = 1 2 3 1 2 3
dlZ(i,j,k) = dlX(i,j,k).*dlY(j)
for indices
i
, j
, and k
. The second
dimension of dlZ
(labeled 'C'
) corresponds to the
second dimension of dlX
and the first dimension of
dlY
.In general, the format of one dlarray
input does not need to be a
subset of the format of another dlarray
input. For example, if
dlX
and dlY
are input arguments with
dims(dlX) = 'SCB'
and dims(dlY) = 'SSCT'
, then
the output dlZ
has dims(dlZ) = 'SSCBT'
. The
'S'
dimension of dlX
maps to the first
'S'
dimension of dlY
.
The 'U'
dimension of a dlarray
behaves differently
from other labeled dimensions in that it exhibits the standard MATLAB singleton dimension behavior. You can think of a formatted
dlarray
as having infinitely many 'U'
dimensions
of size 1 following the dimensions returned by size
.
The software discards a 'U'
label unless the dimension is
nonsingleton or it is one of the first two dimensions of the
dlarray
.
To see an example of this behavior, enter the following code.
X = ones(2,2);
dlX = dlarray(X,'SC')
dlX(:,:,2) = 2
dlX = 2(S) × 2(C) dlarray 1 1 1 1 dlX = 2(S) × 2(C) × 2(U) dlarray (:,:,1) = 1 1 1 1 (:,:,2) = 2 2 2 2
dlarray
to a threedimensional dlarray
, and labels the third dimension with
'U'
by default. For an example of how the 'U'
dimension is used in implicit expansion, see Implicit Expansion with Data Formats.Indexing with a dlarray
is supported and exhibits the following behaviors:
dlX(idx1,...,idxn)
returns a dlarray
with the same data format as dlX
if n
is greater than or equal to ndims(dlX)
. Otherwise, it
returns an unformatted dlarray
.
If you set dlY(idx1,...,idxn) = dlX
, then the data
format of dlY
is preserved, although the software might
add or remove trailing 'U'
dimension labels. The data
format of dlX
has no impact on this operation.
If you delete parts of a dlarray
using
dlX(idx1,…,idxn) = []
, then the data format of
dlX
is preserved if n
is greater
than or equal to ndims(dlX)
. Otherwise,
dlX
is returned unformatted.
When you use a function with a dlarray
input,
the order of the operations within the function can change based on the internal storage order
of the dlarray
. This change can result in differences on the order of roundoff
for two dlarray
objects that are otherwise equal.
dlarray
 dlfeval
 dlgradient
 dlnetwork