フィルターのクリア

how to convert this block of code to python?

3 ビュー (過去 30 日間)
Prb
Prb 2019 年 4 月 17 日
回答済み: Prb 2019 年 5 月 1 日
%convert the weights to -1 and + 1. Store in single because conv2 requires it
for i = 1:length(Filters)
Filters{i} = gpuArray(2*(single(sign(Filters{i}))-0.5));
NumLearntWeightsEachLayer(i) = size(Filters{i},3)*size(Filters{i},4)*4;
end
NumLearntWeightsEachLayer(end) = size(Filters{end},3)*size(Filters{end},4);
NumLearntWeightsEachLayer
TotalLearntWeights = sum(NumLearntWeightsEachLayer)
  4 件のコメント
Prb
Prb 2019 年 5 月 1 日
I would like to have something similar problem solved as a lead to my question.
Walter Roberson
Walter Roberson 2019 年 5 月 1 日
https://stackoverflow.com/questions/40609838/what-is-the-equivalent-to-a-matlab-cell-array

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

回答 (1 件)

Prb
Prb 2019 年 5 月 1 日
I think this is the right answer here
for i in range (0,len(Filters)):
for j in range(0, len(Filters[i]):
Filters[i][j] = (2*(Filters[i][j] - 0.5))
NumLearntWeightsEachLayer[i] = len(Filters[i][3])*len(Filters[i][4])*4
NumLearntWeightsEachLayer[-1] = len(Filters[-1][3])*len(Filters[-1][4])
print NumLearntWeightsEachLayer
TotalLearntWeights = sum(NumLearntWeightsEachLayer)

カテゴリ

Help Center および File ExchangeImage Data Workflows についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by