You can import and visualize training and validation data in Deep Network Designer. Using this app you can:
Import datastore objects for training. After import, Deep Network Designer displays a preview of the data. For more information, see Import Data.
Import training data for image classification problems from an
ImageDatastore
object or a folder containing subfolders of images per
class. You can also select built-in options to augment the training images during
training. For more information, see Image Augmentation.
Import validation data from a datastore object. For image classification you can also select validation data from a folder containing subfolders of images for each class, or choose to split the validation data from the training data. For more information, see Validation Data.
For more information about data sets you can use to get started with deep learning, see Data Sets for Deep Learning. For more information on constructing and using datastore objects for deep learning applications, see Datastores for Deep Learning.
In Deep Network Designer, you can import image classification data from an image
datastore or a folder containing subfolders of images from each class. You can also import
and train any datastore object that works with the trainNetwork
function. Select an import method based on the type of datastore
you are using.
Import ImageDatastore Object | Import Any Other Datastore Object (Not Recommended for
ImageDatastore ) |
---|---|
Select Import Data > Import Image Data.
| Select Import Data > Import Datastore.
|
After import, Deep Network Designer provides a preview of the imported data so that you can check that the data is as expected, prior to training. For image classification data, Deep Network Designer also displays a histogram of the class labels and a random selection of images from the imported data. You can also choose to see random images belonging to a specific class.
Import Data by Task
Task | Data Type | Data Import Method | Example Visualization |
---|---|---|---|
Image classification | Folder with subfolders containing images for each class. The class labels are sourced from the subfolder names. For an example, see Transfer Learning with Deep Network Designer. | Select Import Data > Import Image Data. You can select augmentation options and specify the validation data using the Import Image Data dialog box. After import, Deep Network Designer displays a histogram of the class labels. You can also see random observations from each class. |
|
For example, create an image datastore containing digits data. dataFolder = fullfile(toolboxdir('nnet'),'nndemos', ... 'nndatasets','DigitDataset'); imds = imageDatastore(dataFolder, ... 'IncludeSubfolders',true, ... 'LabelSource','foldernames'); | |||
For example, create an augmented image datastore containing digits data. dataFolder = fullfile(toolboxdir('nnet'),'nndemos', ... 'nndatasets','DigitDataset'); imds = imageDatastore(dataFolder, ... 'IncludeSubfolders',true, ... 'LabelSource','foldernames'); imageAugmenter = imageDataAugmenter( ... 'RandRotation',[1,2]); augimds = augmentedImageDatastore([28 28],imds, ... 'DataAugmentation',imageAugmenter); augimds = shuffle(augimds); | Select Import Data > Import Datastore. You can specify the validation data in the Import Datastore dialog box. After import, Deep Network Designer shows a preview of the first five observations in the datastore. |
| |
Semantic segmentation | For example, combine an
dataFolder = fullfile(toolboxdir('vision'), ... 'visiondata','triangleImages'); imageDir = fullfile(dataFolder,'trainingImages'); labelDir = fullfile(dataFolder,'trainingLabels'); imds = imageDatastore(imageDir); classNames = ["triangle","background"]; labelIDs = [255 0]; pxds = pixelLabelDatastore(labelDir,classNames,labelIDs); cds = combine(imds,pxds); You
can also combine an pximds = pixelLabelImageDatastore(imds,pxds); | Select Import Data > Import Datastore. You can specify the validation data in the Import Datastore dialog box. After import, Deep Network Designer shows a preview of the first five observations in the datastore. |
|
Image-to-image regression | For example, combine noisy input images and pristine output images to create data suitable for image-to-image regression. dataFolder = fullfile(toolboxdir('nnet'),'nndemos', ... 'nndatasets','DigitDataset'); imds = imageDatastore(dataFolder, ... 'IncludeSubfolders',true, .... 'LabelSource','foldernames'); imds = transform(imds,@(x) rescale(x)); imdsNoise = transform(imds,@(x) {imnoise(x,'Gaussian',0.2)}); cds = combine(imdsNoise,imds); cds = shuffle(cds); | Select Import Data > Import Datastore. You can specify the validation data in the Import Datastore dialog box. After import, Deep Network Designer shows a preview of the first five observations in the datastore. |
|
Regression | Create data suitable for training regression networks by combining array datastore objects. [XTrain,~,YTrain] = digitTrain4DArrayData; ads = arrayDatastore(XTrain,'IterationDimension',4, ... 'OutputType','cell'); adsAngles = arrayDatastore(YTrain,'OutputType','cell'); cds = combine(ads,adsAngles); For more information about training a regression network, see Train Convolutional Neural Network for Regression. | Select Import Data > Import Datastore. You can specify the validation data in the Import Datastore dialog box. After import, Deep Network Designer shows a preview of the first five observations in the datastore. |
|
Sequences and time series | Custom datastore For an example, see Train Network Using Custom Mini-Batch Datastore for Sequence Data. | Select Import Data > Import Datastore. You can specify the validation data in the Import Datastore dialog box. After import, Deep Network Designer shows a preview of the first five observations in the datastore. |
|
Other extended workflows (such as numeric feature input, out-of-memory data, image processing, and audio and speech processing) | Datastore For other extended workflows, use a suitable
datastore object. For example, custom datastore, For
example, create a dataFolder = fullfile(toolboxdir('images'),'imdata'); imds = imageDatastore(dataFolder,'FileExtensions',{'.jpg'}); dnds = denoisingImageDatastore(imds,... 'PatchesPerImage',512,... 'PatchSize',50,... 'GaussianNoiseLevel',[0.01 0.1]); | Select Import Data > Import Datastore. You can specify the validation data in the Import Datastore dialog box. After import, Deep Network Designer shows a preview of the first five observations in the datastore. |
|
For image classification problems, Deep Network Designer provides simple augmentation options to apply to the training data. Open the Import Image Data dialog box by selecting Import Data > Import Image Data. You can select options to apply a random combination of reflection, rotation, rescaling, and translation operations to the training data.
You can effectively increase the amount of training data by applying randomized augmentation to your data. Augmentation also enables you to train networks to be invariant to distortions in image data. For example, you can add randomized rotations to input images so that a network is invariant to the presence of rotation in input images. Data augmentation can also help prevent the network from overfitting and memorizing the exact details of the training images. When you use data augmentation, one randomly augmented version of each image is used during each epoch of training, where an epoch is a full pass of the training algorithm over the entire training data set. Therefore, each epoch uses a slightly different data set, but the actual number of training images in each epoch does not change. For more information, see Create and Explore Datastore for Image Classification.
To perform more general and complex image preprocessing operations than those offered by
Deep Network Designer, use TransformedDatastore
and
CombinedDatastore
objects. To
import CombinedDatastore
and TransformedDatastore
objects,
select Import Data > Import Datastore.
For more information on image augmentation, see Preprocess Images for Deep Learning.
In Deep Network Designer, you can import validation data to use during training. Validation data is data that the network does not use to update the weights and biases during training. As the network does not directly use this data, it is useful for assessing the true accuracy of the network during training. You can monitor validation metrics, such as loss and accuracy, to assess if the network is overfitting or underfitting and adjust the training options as required. For example, if the validation loss is much higher than the training loss, then the network might be overfitting.
For more information on improving the accuracy of deep learning networks, see Deep Learning Tips and Tricks.
In Deep Network Designer, you can import validation data:
From a datastore in the workspace.
From a folder containing subfolders of images for each class (image classification data only).
By splitting a portion of the training data to use as validation data (image classification data only).
When splitting the validation data from the training data, Deep Network Designer splits a percentage of the training data from each class. For example, suppose you have a data set with two classes, cat and dog, and choose to use 30% of the training data for validation. Deep Network Designer uses the last 30% of images with the label "cat" and the last 30% with the label "dog" as the validation set.
Rather than using the last 30% of the training data as validation data, you can choose to randomly allocate the observations to the training and validation sets by selecting the Randomize check box in the Import Image Data dialog box. Randomizing the images can improve the accuracy of networks trained on data stored in a nonrandom order. For example, the digits data set consists of 10,000 synthetic grayscale images of handwritten digits. This data set has an underlying order in which images with the same handwriting style appear next to each other within each class. An example of the display follows.
Randomizing ensures that when you split the data, the images are shuffled so that the
training and validation sets contain random images from each class. Using training and
validation data that consists of a similar distribution of images can help prevent
overfitting. Not randomizing the data ensures that the training and validation data split
is the same each time, and can help improve the reproducibility of results. For more
information, see splitEachLabel
.
augmentedImageDatastore
| CombinedDatastore
| Deep Network Designer | imageDatastore
| splitEachLabel
| TransformedDatastore