Why can augmentedImageDatastore cannot handle non-categorical variables

2 次查看(过去 30 天)
When I initialize an augmentedImageDatastore object, I tried to pass in a 4D input matrix and a 1D vector of numeric labels (0 and 1). While the object was initialized, when I tried to train my network, I got this error
Invalid training data. The output size (2) of the last layer doesn't match the number of classes (1).
When this error occurs, I check the label vector to make sure that both classes are represented in the training set, and they are. In addition, when I convert my labels to a categorical type before initializing the augmentedImageDatastore object, it works.
Code
------------
My input images are of size [150 150 3]. The labels vector is of type uint8. I have added an augmenter to my training dataset, but have not added an augmenter to my validation dataset. In doing so, I am assuming that when my network tests on the validation set at intervals specified by the ValidationFrequency in trainingOptions, the validation set will not be augmented.
The reason that I used an augmentedImageDatastore is that an imageDatastore cannot be initialized by a 4D input matrix and a label vector. The way I divide my training, validation, and testing sets does not allow me to store this information in folders. As a result, I cannot initialize an imageDatastore object. My code for creating my training and validation sets are below.
imds_training = augmentedImageDatastore([150 150], training.inputs, training.labels, 'DataAugmentation', augmenter, 'OutputSizeMode', 'centercrop');
imds_validation = augmentedImageDatastore([150 150], validation.inputs, validation.labels); % no augmentation on validation
Questions
-----------
  1. Why do I get an error when I use uint8 type labels? I don't think its the limiting factor, but it would be nice to understand.
  2. Is it correct for me to assume that by initializing my validation set as I did above, my validation set will not be augmented randomly. In other words, using augmentedImageDatastore is just a wrapper to store my inputs and corresponding labels.

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Sequence and Numeric Feature Data Workflows 的更多信息

产品


版本

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by