Load the sample data, which consists of synthetic images of handwritten digits. XTrain
is a 28-by-28-by-1-by-5000 array, where:
28 is the height and width of the images.
1 is the number of channels.
5000 is the number of synthetic images of handwritten digits.
Name Size Bytes Class Attributes
XTrain 28x28x1x5000 31360000 double
Create an imageDataAugmenter
object that specifies preprocessing options for image augmentation, such as resizing, rotation, translation, and reflection. Randomly translate the images up to three pixels horizontally and vertically, and rotate the images with an angle up to 20 degrees.
Create an augmentedImageDatastore
using the image data augmented. When you read from the datastore, for example during network training using the trainnet
function, the datastore performs image augmentation and resizes the images. The datastore augments the images without saving any images to memory.
Create a random permutation of the integers one to the total number of images in the datastore.
Shuffle the images to create a new datastore containing the same images in a random order.
Partition the datastore. The partitionByIndex
function returns a datastore containing 80% of the images.
trainAugimds =
augmentedImageDatastore with properties:
NumObservations: 4000
MiniBatchSize: 128
DataAugmentation: [1×1 imageDataAugmenter]
ColorPreprocessing: 'none'
OutputSize: [64 64]
OutputSizeMode: 'resize'
DispatchInBackground: 0
Partition the datastore using elements of the remaining indices. The partitionByIndex
function returns a datastore containing the remaining 20% of the images.
valAugimds =
augmentedImageDatastore with properties:
NumObservations: 1000
MiniBatchSize: 128
DataAugmentation: [1×1 imageDataAugmenter]
ColorPreprocessing: 'none'
OutputSize: [64 64]
OutputSizeMode: 'resize'
DispatchInBackground: 0