Info
此问题已关闭。 请重新打开它进行编辑或回答。
How to convert this code in vectorize form to be faster?
1 次查看(过去 30 天)
显示 更早的评论
The code below is correct, but I want to vectorize it (and may convert to GPU) to increase the speed.
How can I convert it to vector form?
RF = 4;
inhibatory = 0;
overlap=3;
gap = RF-overlap;
Image1 = rand(30,22);
Image2 = rand(27,19);
Image3 = rand(30,22);
for u=1:size(Image1,1)
for v=1:size(Image1,2)
sum_val=0;
iLowMax=max(ceil((u-(receptiveFieldSize+inhibatory))/(gap-inhibatory)),1);
iHighMax=min(floor((u-1)/(gap-inhibatory))+1, UpperLayerSize(1));
jLowMax=max(ceil((v-(receptiveFieldSize+inhibatory))/(gap-inhibatory)),1);
jHighMax = min(floor((v-1)/(gap-inhibatory))+1, UpperLayerSize(2));
sum_sens = sum(sum(Image2(iLowMax:iHighMax,jLowMax:jHighMax)));
sum_val = sum_sens(:,:) .* Image3(u,v);
act_output = Image1(u,v);
result(u,v) = de_activate_Mat(act_output,act_funct) .* sum_val;
end
end
0 个评论
回答(0 个)
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!