Prepare Data for Quantizing Networks
Quantizing a deep neural network in MATLAB® requires calibration by exercising the network to determine the dynamic ranges of its weights, biases, and activations. After calibrating, you can validate the performance of the quantized network and inspect the reduction in size and performance (if any) of the network. However, not all data formats supported for training and prediction are supported for quantization workflows.
function requires that calibration data be passed as a
datastore object or a numeric array. The
function requires validation data to be passed as a
Passing data as a numeric array is not supported for
built-in datastores are supported for quantization workflows. The supported datastores
for particular networks are detailed below. Passing data as a table is not
For more information on using
datastore objects for training and
prediction, see Datastores for Deep Learning.
Choose a Built-In Datastore
This table describes which built-in datastores are supported for validation and quantization of different network types.
Image classification or regression
Sequence and numeric feature classification and regression
Calibration and Validation
To be a valid input for validation, the
read function of a datastore must return data either as a cell array or as
a table with the responses as the second column.
As calibration exercises the network and collects the dynamic range statistics, the
calibration data does not require responses. In addition to the datastores in the
previous table, calibration supports the use of
The format of the predictors used for calibration and validation depends on the type of input.
|Format of Predictors
h-by-w-by-c numeric array, where h, w, and c are the height, width, and number of channels of the image, respectively.
c-by-s matrix, where c is the number of features of the sequence and s is the sequence length. Each sequence must have the same length.
|2-D image sequence
h-by-w-by-c-by-s array, where h, w, and c correspond to the height, width, and number of channels of the image, respectively, and s is the sequence length.
Each sequence in the mini-batch must have the same sequence length.
1-by-c column vector, where c is the number of features.
For data returned in tables, the elements must contain a 1-by-1 cell array containing a numeric array.
For validation, the datastore must return responses. The format of the responses depends on the type of task.
For calibration data passed as a numeric array, the format of the predictors used for calibration has an additional dimension for the number of batches. For example, vector sequence input data with numeric calibration data is a c-by-s-by-b array, where c is the number of features of the sequence, s is the sequence length, and b is the number of batches.
|Format of Responses
The default format returned by reading from a
Transform and Combine Datastores
Deep learning frequently requires data to be preprocessed and augmented before data is
in an appropriate form to input to a network. The
functions of datastores are useful in preparing data to be fed into a network.
A transformed datastore applies a particular data transformation to an underlying
datastore when reading data. To create a transformed datastore, use the
transform function and specify the underlying datastore and the
For validation, reading from a transformed datastore must return a cell array with the predictors as the first column and the responses as the third column.
combine function combines data from multiple datastores. Operating
on the resulting
such as resetting the datastore, performs the same operation on all of the
functions support only
objects with two underlying datastores. The first datastore must be an
arrayDatastore and the second datastore must be a
pixelLabelDatastore (Computer Vision Toolbox) or