Borrar filtros
Borrar filtros

How to train resnet50 model on multiple input?

6 visualizaciones (últimos 30 días)
john karli
john karli el 27 de Dic. de 2021
Comentada: john karli el 28 de Dic. de 2021
I am following the belw link to make the multiple input network
but my dataset is different from the above link. I have time series data with shape (1,1024,2) in .mat file and data with 2 channel (224,224,2) .mat file. How do i make the image datastore as upperhalf and bottom half

Respuestas (1)

yanqi liu
yanqi liu el 27 de Dic. de 2021
yes,sir,may be use addLayers、connectLayers to merge net layers
  1 comentario
john karli
john karli el 28 de Dic. de 2021
I have tried but get the error my code is
trainpath1 = fullfile("D:\folder\");
trainpath2 = fullfile("E:\Classes\");
%imds1 = imageDatastore(trainpath1, 'IncludeSubfolders',true, 'FileExtensions','.PNG','LabelSource','foldernames');
imds1 = imageDatastore(trainpath1, 'FileExtensions', '.mat', 'IncludeSubfolders',true, ...
'LabelSource','foldernames',...
'ReadFcn',@matReader);
imds2 = signalDatastore(trainpath2,'SignalVariableNames',["frame","label"],'IncludeSubfolders',true,'FileExtensions','.mat');
%imds2 = imageDatastore(trainpath2, 'IncludeSubfolders',true, 'FileExtensions','.PNG','LabelSource','foldernames');
labelds = fileDatastore('labels.mat','ReadFcn',@myReadFcn,'ReadMode','partialfile');
cds = combine(imds1,imds2,labelds);
% Change the image sizes accordingly
imsize1 = [656 875 2];
imsize2 = [1 1024 2];
numClasses = 11;
%% Define muliple input network
layers1 = [
imageInputLayer(imsize1,'Name','input1')
convolution2dLayer(3,16,'Padding','same','Name','conv_1')
reluLayer('Name','relu_1')
fullyConnectedLayer(10,'Name','fc11')
additionLayer(2,'Name','add')
fullyConnectedLayer(numClasses,'Name','fc12')
softmaxLayer('Name','softmax')
classificationLayer('Name','classOutput')];
lgraph = layerGraph(layers1);
layers2 = [imageInputLayer(imsize2,'Name','input2')
convolution2dLayer(3,16,'Padding','same','Name','conv_2')
reluLayer('Name','relu_2')
fullyConnectedLayer(10,'Name','fc21')];
lgraph = addLayers(lgraph,layers2);
lgraph = connectLayers(lgraph,'fc21','add/in2');
plot(lgraph)
%% Define trainingOptions and also set 'Shuffle' to 'never' for this workaround to work
options = trainingOptions('adam', ...
'InitialLearnRate',0.001, ...
'LearnRateSchedule','piecewise',...
'MaxEpochs',3, ...
'MiniBatchSize',128, ...
'Verbose',1, ...
'Plots','training-progress');
net = trainNetwork(cds,lgraph,options);
error
Error using trainNetwork (line 184)
Dimensions of arrays being concatenated are not consistent.
Caused by:
Error using horzcat
Dimensions of arrays being concatenated are not consistent.

Iniciar sesión para comentar.

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by