Divide a 4D array into training set and validation set for CNN (regression)
Show older comments
Hi everybody, I am trying to design a CNN for regression following this Matlab example. It uses a 4D array to store the images and vector to store the values associated to every picture. I am using this code to create a 4D array called 'database' that contains my images and a vector 'labels' that contains the values.
k = 1;
%2cm
for i = 1:1000
str = sprintf('images/2cm/%d.jpg', i);
image_to_store = imread(str);
database(:,:,1,k) = (image_to_store(:,:)); % images are in grey scale
labels(k) = 2;
k = k+1;
end
%20cm
for i = 1:1000
str = sprintf('images/20cm/%d.jpg', i);
image_to_store = imread(str);
database(:,:,1,k) = (image_to_store(:,:));
labels(k) = 20;
k = k+1;
end
% ...
Now, I have my 4D array and the vector, so I am trying to divide them into a Training Set and a Validation Set as suggested in the example linked. Can anyone please help me to understand how can I do that?
Thanks
Vale
1 Comment
Muhammad Waris
on 31 Mar 2021
hello, what was the size of image? I am trying to do the similar work, made 4Darraydata and also divided that for training and testing.But when i strat to train this code https://ch.mathworks.com/help/deeplearning/ug/train-a-convolutional-neural-network-for-regression.html i encounter with an error "Insufficient number of outputs from right hand side of equal sign to satisfy assignment".
Accepted Answer
More Answers (0)
Categories
Find more on Object Detection in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!