Divide a 4D array into training set and validation set for CNN (regression)
显示 更早的评论
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 个评论
Muhammad Waris
2021-3-31
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".
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Object Detection 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!