How to train a vector multiple-input multiple-output network
Afficher commentaires plus anciens
I want to train a vector multi-input, multi-output network, but I get the error “Number of input data formats (1) and number of network inputs (2) must match”. This is the code,
clear
input1ds=signalDatastore("input1.csv")
input2ds=signalDatastore("input2.csv")
output1ds=signalDatastore("output1.csv")
output2ds=signalDatastore("output2.csv")
ds=combine(input1ds,input2ds,output1ds,output2ds)
isShuffleable(ds)
% 入力とターゲット
% x = [[0:0.1:10]' [0:0.1:10]']
% t = sin(x)
net=dlnetwork
% ニューラルネットワークの定義
layers1 = [
featureInputLayer(1,"name","input1")
fullyConnectedLayer(10) % 10ユニットの全結合層
tanhLayer
fullyConnectedLayer(10) % 10ユニットの全結合層
tanhLayer
fullyConnectedLayer(1) % 1ユニットの全結合層
];
layers2 = [
featureInputLayer(1,"Name","input2")
fullyConnectedLayer(10) % 10ユニットの全結合層
tanhLayer
fullyConnectedLayer(10) % 10ユニットの全結合層
tanhLayer
fullyConnectedLayer(1) % 1ユニットの全結合層
];
net=addLayers(net,layers1)
net=addLayers(net,layers2)
net.plot
% layers=layerGraph()
% layers=addLayers(layers,layers1)
% layers=addLayers(layers,layers2)
% オプションの設定
options = trainingOptions('sgdm', ... % 最適化アルゴリズム
'MaxEpochs', 500, ... % 最大エポック数
'MiniBatchSize', 2^3, ... % ミニバッチサイズ
'Verbose', true,...% 進行状況の表示
'InputDataFormats', {'SB'} ...
)
% ニューラルネットワークのトレーニング
customLossFunction = @(Y, T) customloss(Y, T);
net = trainnet(ds,net,customLossFunction,options) % x,tは縦ベクトル
The “input1.csv” and “output1.csv” all contain a single column of vertical vectors. This time, it is a 2-input, 2-output network.
The function “customloss” is a function I defined myself. This is the error statement.
Error using trainnet (line 46)
Number of input data formats (1) and number of network inputs (2) must match.
Error in parallel_learn_test (line 53)
net = trainnet(ds,net,customLossFunction,options) % x,tは縦ベクトル
What is wrong? And what solutions are available?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Deep Learning Toolbox dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!