Index exceeds the number of array elements (4).というエラーについて

2 ビュー (過去 30 日間)
ssk
ssk 2019 年 2 月 15 日
コメント済み: ssk 2019 年 2 月 17 日
プログラミング初心者です。
以下は当方のディレクトリ構造です。
main
-- a
-- image.dcm(10 dicom file)
 -- b
  -- image.dcm(10 dicom file)
 -- c
  -- image.dcm(10 dicom file)
-- d
  -- image.dcm(10 dicom file).
%path = current directory
currentdirectory = pwd;
categories = {'a', 'b', 'c','d'};
%Create an ImageDatastore to help you manage the data.
imds = imageDatastore(fullfile(currentdirectory, categories),'IncludeSubfolders',true,'FileExtensions','.dcm','LabelSource', 'foldernames');
現在、上記のコードを作り、alexnetを導入したところ、以下のエラーがでました。
※リンクの事前学習済のネットワークの読み込みの箇所からalexnetのコードを使っています
リンク:https://jp.mathworks.com/help/deeplearning/examples/transfer-learning-using-alexnet.html
Index exceeds the number of array elements (4).
どのように解決すべきかご教示いただけますと幸いです。どうぞよろしくお願いいたします。

採用された回答

Kenta
Kenta 2019 年 2 月 17 日
layers = [
layersTransfer
fullyConnectedLayer(4,'WeightLearnRateFactor',20,'BiasLearnRateFactor',20)
softmaxLayer
classificationLayer];
レイヤーの定義のときに、層の数を4にすればよいと思います。上のように、fullyConnectedLayerの直後にカテゴリーの数である4を打てば正しく実行できると思うのですが、いかがでしょうか。
  1 件のコメント
ssk
ssk 2019 年 2 月 17 日
本当にありがとうございます!おかげさまでalexnet動きました!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File Exchangeイメージを使用した深層学習 についてさらに検索

Community Treasure Hunt

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

Start Hunting!