Issues loading labels in Deep Network Analyzer
조회 수: 4 (최근 30일)
이전 댓글 표시
Hello all,
I am configuring a neural network for keypoint detection. Each input is an image, and the label for each image is one single number. This number corresponds to a value in the xcoordinate of the image.
I have a table with the labels for my images, and I am assigning the right label to each image in the datastore by doing the following:
%ground truth is a table, pos_pixel is one of its cols, containing the
%label I need for that image
%the resulting img_datastore.Labels is an array of doubles
img_datastore.Labels(j) = ground_truth.pos_pixel(i);
After creating these labels, I go to "import custom data", and get the following:
"Invalid training data. The labels of the ImageDatastore must be a categorical vector."
Does anyone know why this could be happening? Thanks in advance.
답변 (1개)
Aniketh
2023년 7월 8일
Hi,
In the trainNetwork function, the response input (Labels) is expected to be a categorical array. However, in the provided code, the labels are assigned directly from a table column, and ends up as an array.
To resolve this issue, you need to convert the labels to a categorical vector using the categorical() function. To fix the problem, modify the code as follows:
img_datastore.Labels(j) = categorical(ground_truth.pos_pixel(i));
For more information you can read up on these pages:
Hope this was helpful!
댓글 수: 2
Aniketh
2023년 7월 10일
According to the documentation on imageDatastore, the lables can be of the type categorical | cell | logical | double | single | string, so probably what is happening here is when you load the images, it is assigning labels as the filenames, and not allowing you to change the datatype.
You can read more about how this works at imageDatastore. One workaround to this is using the combine function and use it to create a CombinedDatastore. You would have to store the labels as a datastore object to accomplish this, there is suffecient documentation on how to convert tabular/spreadsheets etc . It would require some extra work, but can be done.
Using imageDatastore give you a very abstracted view of these operations, and thus provides less customizability such as labelling images directly through tables, hope this helped!
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Data Workflows에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!