勾配の出力結果がゼロになる
2 views (last 30 days)
Show older comments
複数入力ネットワークを用いて,Softmaxと畳み込み層の勾配を計算しようとしています.
しかし,勾配の出力結果を確認すると,全てゼロになっています.
勾配計算前までは,共に値が計算されています.
どのような問題が考えられるでしょうか.
・勾配計算用の関数の中身
function [featureMap, dl_featureMap] = gradcam_fun(dlnet, dlImg, dlImg2, dlImg3)
% mul_1 -> 乗算された畳み込み層
[featureMap, scores] = predict(dlnet, dlImg, dlImg2, dlImg3, 'Outputs', {'mul_1', 'softmax'});
dl_featureMap = dlgradient(max(scores), featureMap);
end
・コード本体
dlnet = dlnetwork(lgraph);
dlImg = dlarray(single(img),'SSC');
dlImg2 = dlarray(single(img2), 'SSC');
dlImg3 = dlarray(single(img3), 'SSC');
% 勾配計算
[featureMap, dl_featureMap] = dlfeval(@gradcam_fun, dlnet, dlImg, dlImg2, dlImg3);
0 Comments
Answers (0)
See Also
Categories
Find more on Clocks and Timers 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!