Borrar filtros
Borrar filtros

Why can augmentedImageDatastore cannot handle non-categorical variables

1 visualización (últimos 30 días)
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.

Respuestas (0)

Categorías

Más información sobre Image Data Workflows en Help Center y File Exchange.

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by