DAGネットワークにおける複数入力について
3 views (last 30 days)
Show older comments
複数入力のDAGネットワークの設計を考えています。
下記図はイメージです。

上記のような複数のimageinputにそれぞれ異なる画像を入力したいと考えています。
trainNetworkの関数を用いる際、どのように書いて、指定すればよろしいでしょうか?
よろしくお願いいたします。
3 Comments
Accepted Answer
Shunichi Kusano
on 6 Feb 2020
こんにちは。
複数入力一出力の場合(Multi Input Signle Output = MISO)、combine関数でデータストアをひとまとめにしてからtrainNetworkに入力します。このとき、ラベルも一緒にcombineしてあげる必要があるのですが、ラベルだけを管理するdatastoreは現状無いため、ここだけカスタムで作成する必要があります。正式なサポートプロダクトではありませんが、カテゴリカルデータを扱えるカスタムのdatastoreを添付しますので、お使いください。
以上を踏まえてコードの大まかな流れは以下のようになります。
% 画像のデータストアは準備しておく。imds1, imds2とする
% ラベルのデータストアを作成(ラベルはカテゴリカル型のベクトルとして作成しておく。categoricalVectorとする。
labelds = CategoricalDatastore(categoricalVector); % 添付のプログラムを使う
% combineで画像1、画像2、ラベルのデータストアをひとまとめにする
combds = combine(imds1, imds2, labelds);
% 学習(ネットワークとオプションはすでにできているとして)
net = trainNetwork(combds, lgraph, options);
ネットワークにおける入力層の順番は、作成したレイヤーグラフのInputNamesというフィールドでわかります。この順番と、combineした順が対応しますので、combineで入力した一番目のimds1はInputNames(1)に、2番目のimds2はInputNames(2)の入力層に投入されます。今回はどちらでもいいかもしれませんが…。
augmentationなどが必要な場合は、transform関数でtransformedDatastoreを作って、それをcombineするのがいいです。
作成していてまたわからないことがありましたら質問してください。
下記は参考まで
combinedDatastore: https://www.mathworks.com/help/matlab/ref/matlab.io.datastore.combineddatastore.html
trainNetworkでのcombinedDatastoreの関連記述:
7 Comments
Rd
on 17 Nov 2020
Dear Kenta,
I too need to do the same thing asmentioned by Yuki Yoshino. I have sequence of six convolutional, relu, batchnormalization and maxpooling layer. i have trained the network with three separate images. Finally i need to fuse these three output. At which layer i have to perform fusion and why? how to do fusion?
Thanks.
More Answers (0)
See Also
Categories
Find more on イメージを使用した深層学習 in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!