I need to do the following and I am wondering if they can be done in a much simple and efficient way.
s = size(relu);
M = s(1) * s(2);
N = s(3);
delta = single(zeros(s));
for i = 1 : s(1)
for j = 1 : s(2)
for k = 1 : s (3)
if relu(i, j, k) > 0
delta(i, j, k) = reshape(relu(i, j, :), [1, s(3)]) * gamma(:, k) / M / M / N / N;
else
delta(i, j, k) = 0;
end
end
end
end

 採用された回答

Andrei Bobrov
Andrei Bobrov 2016 年 9 月 13 日
編集済み: Andrei Bobrov 2016 年 9 月 13 日

2 投票

Let your gamma -> gamma1 (because gamma - name of the function from MATLAB)
s = size(relu);
M = s(1) * s(2);
N = s(3);
r1 = reshape(relu,[],s(3));
delta1 = reshape(r1*gamma1,s).*(relu > 0)/(M*N)^2;

1 件のコメント

fireman
fireman 2016 年 9 月 14 日
It worked very well. Thanks,

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

その他の回答 (0 件)

質問済み:

2016 年 9 月 13 日

コメント済み:

2016 年 9 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by