필터 지우기
필터 지우기

How do i train a deep cnn network with multi input with 4 folders of images?

조회 수: 8 (최근 30일)
Hi,
I have to train the following network( composed by 4 alexNet pretrained network concatenated into a regression network):
Where every data_1 has an input image [227 227 3].
My idea was this
% IMAGE T/V/T DIVISION
p='\pato';
trasform=["\cwt" "\hht" "\sswt" "\time"];
directory = strcat(selpath,'\crossvalidation K=10');
directory = strcat(directory,'\f');
directory = strcat(directory,string(k));
directory_train = strcat(directory,'\train');
directory_test = strcat(directory,'\test');
directory_val = strcat(directory,'\val');
trainImgsALEX_SQ_cwt = imageDatastore(strcat(directory_train,'\alexsqueeze',p,trasform(1)),'IncludeSubfolders',true,'LabelSource','foldernames');
trainImgsALEX_SQ_hht = imageDatastore(strcat(directory_train,'\alexsqueeze',p,trasform(2)),'IncludeSubfolders',true,'LabelSource','foldernames');
trainImgsALEX_SQ_sswt = imageDatastore(strcat(directory_train,'\alexsqueeze',p,trasform(3)),'IncludeSubfolders',true,'LabelSource','foldernames');
trainImgsALEX_SQ_time = imageDatastore(strcat(directory_train,'\alexsqueeze',p,trasform(4)),'IncludeSubfolders',true,'LabelSource','foldernames');
trainImagesALEX_SQ = combine(trainImgsALEX_SQ_cwt,trainImgsALEX_SQ_hht,trainImgsALEX_SQ_sswt,trainImgsALEX_SQ_time);
testImgsALEX_SQ_cwt = imageDatastore(strcat(directory_test,'\alexsqueeze',p,trasform(1)),'IncludeSubfolders',true,'LabelSource','foldernames','FileExtensions','.jpg');
testImgsALEX_SQ_hht = imageDatastore(strcat(directory_test,'\alexsqueeze',p,trasform(2)),'IncludeSubfolders',true,'LabelSource','foldernames','FileExtensions','.jpg');
testImgsALEX_SQ_sswt = imageDatastore(strcat(directory_test,'\alexsqueeze',p,trasform(3)),'IncludeSubfolders',true,'LabelSource','foldernames','FileExtensions','.jpg');
testImgsALEX_SQ_time = imageDatastore(strcat(directory_test,'\alexsqueeze',p,trasform(4)),'IncludeSubfolders',true,'LabelSource','foldernames','FileExtensions','.jpg');
testImgsALEX_SQ=combine(testImgsALEX_SQ_cwt,testImgsALEX_SQ_hht,testImgsALEX_SQ_sswt,testImgsALEX_SQ_time);
valImgsALEX_SQ_cwt = imageDatastore(strcat(directory_val,'\alexsqueeze',p,trasform(1)),'IncludeSubfolders',true,'LabelSource','foldernames','FileExtensions','.jpg');
valImgsALEX_SQ_hht = imageDatastore(strcat(directory_val,'\alexsqueeze',p,trasform(1)),'IncludeSubfolders',true,'LabelSource','foldernames','FileExtensions','.jpg');
valImgsALEX_SQ_sswt = imageDatastore(strcat(directory_val,'\alexsqueeze',p,trasform(1)),'IncludeSubfolders',true,'LabelSource','foldernames','FileExtensions','.jpg');
valImgsALEX_SQ_time = imageDatastore(strcat(directory_val,'\alexsqueeze',p,trasform(1)),'IncludeSubfolders',true,'LabelSource','foldernames','FileExtensions','.jpg');
valImgsALEX_SQ=combine(valImgsALEX_SQ_cwt,valImgsALEX_SQ_hht,valImgsALEX_SQ_sswt,valImgsALEX_SQ_time);
all of this is inside a for k=1:10 for the k-fold cross validation, and the dataset for training,test, val is divided(for every fold) into 4 folders of images.
Now, if i train the network with the combinedatastore, will this work?If that can be done.
Otherwise, how can i train it in order to have multiple input images from these folders?
Also, I'm having a problem on the concatenation layer
How can i overcome this?
Feel free to propose your way of solving this, doesn't have to be this way only.
Thanks in advance.

답변 (1개)

V Sairam Reddy
V Sairam Reddy 2023년 4월 20일
Hi Christian,
I understand that you want to train a multi input deep learning network with 4 inputs.
In general, the workflow is to specify a network architecture using a 'layerGraph' object and then train the network using 'trainNetwork' function with datastore input.
With the datastore, you can use the 'combine' and 'transform' functions to create a cell array with 5 columns, where the first 4 columns specify the predictors for each input and the last column specifies the responses. The order of inputs is given by the "InputNames" property of the layer graph layers.
Please find this example to understand the workflow better:
Please find the following resources explaining the training of multi-input network without datastores:
I hope this helps.

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by