画像の代わりに2次元​データを入力にして深​層学習を行いたいので​すが、どのように入力​すればよいでしょうか​?

15 vues (au cours des 30 derniers jours)
KM
KM le 29 Sep 2022
Commenté : KM le 3 Oct 2022
画像ではなく、2次元のデータを入力とするCNNをつくりたいのですが、どのように入力すればよろしいでしょうか?
現状は、31×9000doubleのデータ3600個が3600×1のcell配列に格納されており、ラベルは3600×1のカテゴリカル変数に設定されています。このままでは「無効な学習データです。」とエラーが出ます。
適したデータストアの作り方や入力の手法をご教示いただけますと幸いです。
よろしくお願いいたします。

Réponse acceptée

Hiro Yoshino
Hiro Yoshino le 30 Sep 2022
画像のネットワークを利用して、trainNetwork 関数で学習する場合は cell が引数として適当では無いです。こちら から対応している型 (datastore等) を確認し、cell を変換すれば利用できると思います。
c = {[1 2;3 4]; [5 6; 7 8]}
c = 2×1 cell array
{2×2 double} {2×2 double}
c_array = cat(3,c{:})
c_array =
c_array(:,:,1) = 1 2 3 4 c_array(:,:,2) = 5 6 7 8
とすれば、画像っぽく array に変換できますよね。
  2 commentaires
Atsushi Ueno
Atsushi Ueno le 1 Oct 2022
対応する型 (datastore等) ⇒ datastore以外に数値配列もありますが cell 配列はありません。
上記事例は分類学習ではなく回帰学習の例ですが、datastoreではなく数値配列を入力する点が参考になります。分類学習の事例として実際に動かしてみると下記の様になります。メモリが足りないので画像サイズを31*900に変更しています。
% 31×9000doubleのデータ3600個が3600×1のcell配列に格納されており
data_cell = cellfun(@(x) zeros(31,900),cell(3600,1),'uni',false);
% ラベルは3600×1のカテゴリカル変数に設定
label = repmat(categorical({'tekito1'; 'tekito2'; 'tekito3'}),1200,1);
% 上記回答の通り cell 配列を数値配列に変換する(この例では"チャネル"を増やし4次元にする)
data_array = cat(4, data_cell{:});
whos
Name Size Bytes Class Attributes cmdout 1x33 66 char data_array 31x900x1x3600 803520000 double data_cell 3600x1 803894400 cell label 3600x1 3956 categorical
layers = [imageInputLayer([31 900]) convolution2dLayer(5,20) reluLayer maxPooling2dLayer(2,'Stride',2) fullyConnectedLayer(3) softmaxLayer classificationLayer];
options = trainingOptions('sgdm','MaxEpochs',20,'InitialLearnRate',1e-4,'Verbose',false,'Plots','training-progress');
net = trainNetwork(data_array,label,layers,options); % ここ(リモート環境)では動かせない
Error using trainNetwork
This functionality is not available on remote platforms.

Caused by:
Error using matlab.internal.lang.capability.Capability.require
This functionality is not available on remote platforms.
KM
KM le 3 Oct 2022
お二方とも、ありがとうございます!
お答えいただいた方法で無事解決できました!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur イメージを使用した深層学習 dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!