How can I train multi-input deep network without DataStore
古いコメントを表示
I want to build two inputs, one output network.
But the first input is an image and the second input is a vector.
When I try to train the network with cell array including two sub arrays (one for images, one for vector), I got an error.
"Invalid training data for multiple-input network. For multiple-input training, use a single datastore."
I created 4D image array, a vector array for each input and labels array for training.
How can I combine these data to a DataStore.
Matlab Datastore couldn't get the data from defined variable from workspace.

2 件のコメント
Y. K.
2020 年 4 月 30 日
Srivardhan Gadila
2021 年 10 月 5 日
From R2020b onwards we can directly use arrayDatastore function instead of saving the data to disk and loading it, as mentioned in the answer. For versions less than R2020b the answer would be the workaround.
採用された回答
その他の回答 (1 件)
David Willingham
2022 年 3 月 11 日
0 投票
Please see this example, released in R2022a that shows how train a multi-input network. It still uses datastores, but shows how they can be combined easily.
3 件のコメント
zhushaolong
2022 年 3 月 13 日
dsX1Train = arrayDatastore(X1Train,IterationDimension=4);
dsX2Train = arrayDatastore(X2Train);
dsTTrain = arrayDatastore(TTrain);
dsTrain = combine(dsX1Train,dsX2Train,dsTTrain);
%%
lgraph = layerGraph();
tempLayers = [
imageInputLayer([224 224 3],"Name","imageinput_1")
convolution2dLayer([3 3],8,"Name","conv_1","Padding","same")
batchNormalizationLayer("Name","batchnorm_1")
reluLayer("Name","relu_1")
averagePooling2dLayer([2 2],"Name","avgpool2d_1","Stride",[2 2])
convolution2dLayer([3 3],16,"Name","conv_2","Padding","same")
batchNormalizationLayer("Name","batchnorm_2")
reluLayer("Name","relu_2")
averagePooling2dLayer([2 2],"Name","avgpool2d_2","Stride",[2 2])
convolution2dLayer([3 3],32,"Name","conv_3","Padding","same")
batchNormalizationLayer("Name","batchnorm_3")
reluLayer("Name","relu_3")
convolution2dLayer([3 3],32,"Name","conv_4","Padding","same")
batchNormalizationLayer("Name","batchnorm_4")
reluLayer("Name","relu_4")
dropoutLayer(0.2,"Name","dropout")
fullyConnectedLayer(1,"Name","fc_1")];
lgraph = addLayers(lgraph,tempLayers);
tempLayers = [
imageInputLayer([1 46 1],"Name","imageinput_2")
fullyConnectedLayer(1,"Name","fc_2")];
lgraph = addLayers(lgraph,tempLayers);
tempLayers = [
concatenationLayer(2,2,"Name","concat")
fullyConnectedLayer(1,"Name","fc_3")
regressionLayer("Name","regressionoutput")];
lgraph = addLayers(lgraph,tempLayers);
clear tempLayers;
lgraph = connectLayers(lgraph,"fc_2","concat/in1");
lgraph = connectLayers(lgraph,"fc_1","concat/in2");
%%
options = trainingOptions("sgdm", ...
MaxEpochs=15, ...
InitialLearnRate=0.001, ...
Plots="training-progress", ...
Verbose=0);
net = trainNetwork(dsTrain,lgraph,options);

我引用了这个例子,but,
Warning: Training stops at iteration 3 because the training loss is NaN. Predictions using the output network may contain NaN values.
san su
2022 年 3 月 17 日
I have 6 inputs, 1 output. The network does not work. I do not know why. "error: 无效的输入层。网络最多只能包含一个序列输入层。"
鑫 陈
2022 年 5 月 25 日
For unsupervised multi-input neural networks, without labels,I do not know how to define the labels in the third column and how to generate training data with combine, such as the image regression problem of two image inputs?
カテゴリ
ヘルプ センター および File Exchange で Deep Learning Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!