前提・実現したいこと
ここに質問の内容を詳しく書いてください。
matlabの”LSTMLayer”のツールを用いて、深層学習長短期記憶(LSTM)ネットワークを作成しています。データとしてcsvファイルを使用したいのですが、以下のエラーが発生しました。
発生している問題・エラーメッセージ
出力引数が多すぎます。 エラー: LSTMLayer (行 14) [XTrain,YTrain] = ('data.csv');
該当のソースコード
matlab
1layer = lstmLayer(100,'Name','lstm1') 2 3inputSize = 12; 4numHiddenUnits = 100; 5numClasses = 9; 6 7layers = [ ... 8 sequenceInputLayer(inputSize) 9 lstmLayer(numHiddenUnits) 10 fullyConnectedLayer(numClasses) 11 softmaxLayer 12 classificationLayer] 13 14[XTrain,YTrain] = ('data.csv'); 15 16figure 17plot(XTrain{1}') 18title("Training Observation 1") 19numFeatures = size(XTrain{1},1); 20legend("Feature " + string(1:numFeatures),'Location','northeastoutside') 21 22inputSize = 12; 23numHiddenUnits = 100; 24numClasses = 9; 25 26layers = [ ... 27 sequenceInputLayer(inputSize) 28 lstmLayer(numHiddenUnits,'OutputMode','last') 29 fullyConnectedLayer(numClasses) 30 softmaxLayer 31 classificationLayer] 32 33maxEpochs = 70; 34miniBatchSize = 27; 35 36options = trainingOptions('adam', ... 37 'ExecutionEnvironment','cpu', ... 38 'MaxEpochs',maxEpochs, ... 39 'MiniBatchSize',miniBatchSize, ... 40 'GradientThreshold',1, ... 41 'Verbose',false, ... 42 'Plots','training-progress'); 43 44net = trainNetwork(XTrain,YTrain,layers,options); 45[XTest,YTest] = ('data.csv'); 46YPred = classify(net,XTest,'MiniBatchSize',miniBatchSize); 47acc = sum(YPred == YTest)./numel(YTest) 48 49numFeatures = 12; 50numHiddenUnits = 100; 51numClasses = 9; 52layers = [ ... 53 sequenceInputLayer(numFeatures) 54 lstmLayer(numHiddenUnits,'OutputMode','last') 55 fullyConnectedLayer(numClasses) 56 softmaxLayer 57 classificationLayer]; 58 59numFeatures = 12; 60numHiddenUnits = 100; 61numClasses = 9; 62layers = [ ... 63 sequenceInputLayer(numFeatures) 64 lstmLayer(numHiddenUnits,'OutputMode','sequence') 65 fullyConnectedLayer(numClasses) 66 softmaxLayer 67 classificationLayer]; 68 69numFeatures = 12; 70numHiddenUnits = 125; 71numResponses = 1; 72 73layers = [ ... 74 sequenceInputLayer(numFeatures) 75 lstmLayer(numHiddenUnits,'OutputMode','last') 76 fullyConnectedLayer(numResponses) 77 regressionLayer]; 78 79numFeatures = 12; 80numHiddenUnits = 125; 81numResponses = 1; 82 83layers = [ ... 84 sequenceInputLayer(numFeatures) 85 lstmLayer(numHiddenUnits,'OutputMode','sequence') 86 fullyConnectedLayer(numResponses) 87 regressionLayer]; 88 89numFeatures = 12; 90numHiddenUnits1 = 125; 91numHiddenUnits2 = 100; 92numClasses = 9; 93layers = [ ... 94 sequenceInputLayer(numFeatures) 95 lstmLayer(numHiddenUnits1,'OutputMode','sequence') 96 dropoutLayer(0.2) 97 lstmLayer(numHiddenUnits2,'OutputMode','last') 98 dropoutLayer(0.2) 99 fullyConnectedLayer(numClasses) 100 softmaxLayer 101 classificationLayer]; 102 103numFeatures = 12; 104numHiddenUnits1 = 125; 105numHiddenUnits2 = 100; 106numClasses = 9; 107layers = [ ... 108 sequenceInputLayer(numFeatures) 109 lstmLayer(numHiddenUnits1,'OutputMode','sequence') 110 dropoutLayer(0.2) 111 lstmLayer(numHiddenUnits2,'OutputMode','sequence') 112 dropoutLayer(0.2) 113 fullyConnectedLayer(numClasses) 114 softmaxLayer 115 classificationLayer]; 116
試したこと
writecsvまたはreadtable('filename.csv');を使ってcsvの読み込みを試みました。
補足情報(FW/ツールのバージョンなど)
ツール:mathworks
用いているcsvデータはファイル名:"data.csv"、データ数:30 × 1000データを使用しています。また、参考にしたURLを以下に示します。
参考URL : https://jp.mathworks.com/help/deeplearning/ref/nnet.cnn.layer.lstmlayer.html
あなたの回答
tips
プレビュー