how to train deep learning network with multi-inputs

조회 수: 41 (최근 30일)
Lina Chato
Lina Chato 2019년 11월 7일
댓글: Hon Wah Yeung 2021년 8월 4일
Hi I need to train a CNN with two different type of images, so I used the following code
inputSize = [64 64 64 4];
inputLayer = image3dInputLayer(inputSize,'Normalization','none','Name','input');
inputLayer2 = image3dInputLayer(inputSize,'Normalization','none','Name','input2');
when I used analyzeNetwork(lgraph), I got error that should only one input layer be used. So please is there any way I can use multi inputs in the matlab?
Also, if multi inputes is supported in matlab, how can define the two different inputs in the training process ( trainNetwork(dsTrain,lgraph,options);)
I appreciate your advice!
Thanks
  댓글 수: 2
Kenta
Kenta 2020년 3월 31일
You can use multi-input CNN with "custom training loop" as it is started to be supported from 2019b. The below is an example. I hope it can help you.
Hon Wah Yeung
Hon Wah Yeung 2021년 8월 4일
There is an easier way to by-pass it as the inputSize for the 2 inputs are the same.
Just simply stack the 2 inputs channel-wise and use grouped-convolution with number of groups set as 2. Or if you want the learning to be done differently for the 2 inputs, you can create your own layer to split the stacked input into 2 outputs.

댓글을 달려면 로그인하십시오.

채택된 답변

Sai Bhargav Avula
Sai Bhargav Avula 2019년 11월 14일
Hi,
You can either use the CombinedDatastore or define a custom layer that can take multiple inputs. For defining a custom layer with multiple inputs you can follow the following link
Additionally the transformedDatastore will also serve the purpose.
Hope this helps !

추가 답변 (0개)

카테고리

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