how to implement CBAM with a pretarined network in matlab. i have seen tutorials doing this on other platforms but not on matlab.
10 次查看(过去 30 天)
显示 更早的评论
%this is the code i found on GitHub but couldn't implement it
lgraph = layerGraph();
tempLayers = imageInputLayer([227 227 3],"Name","imageinput");
lgraph = addLayers(lgraph,tempLayers);
tempLayers = maxPooling2dLayer([5 5],"Name","maxpool_1","Padding","same");
lgraph = addLayers(lgraph,tempLayers);
tempLayers = averagePooling2dLayer([5 5],"Name","avgpool2d_1","Padding","same");
lgraph = addLayers(lgraph,tempLayers);
tempLayers = [
multiplicationLayer(2,"Name","multiplication_1")
fullyConnectedLayer(10,"Name","fc_1")
fullyConnectedLayer(10,"Name","fc_2")
fullyConnectedLayer(10,"Name","fc_3")
leakyReluLayer(0.01,"Name","leakyrelu_1")];
lgraph = addLayers(lgraph,tempLayers);
tempLayers = averagePooling2dLayer([5 5],"Name","avgpool2d_2","Padding","same");
lgraph = addLayers(lgraph,tempLayers);
tempLayers = maxPooling2dLayer([5 5],"Name","maxpool_2","Padding","same");
lgraph = addLayers(lgraph,tempLayers);
tempLayers = [
multiplicationLayer(2,"Name","multiplication_2")
leakyReluLayer(0.01,"Name","leakyrelu_2")
sigmoidLayer("Name","sigmoid")
yolov2OutputLayer([16 16;32 32],"Name","yolov2-out")];
lgraph = addLayers(lgraph,tempLayers);
% 清理辅助变量
clear tempLayers;
%链接所有层
lgraph = connectLayers(lgraph,"imageinput","maxpool_1");
lgraph = connectLayers(lgraph,"imageinput","avgpool2d_1");
lgraph = connectLayers(lgraph,"maxpool_1","multiplication_1/in2");
lgraph = connectLayers(lgraph,"avgpool2d_1","multiplication_1/in1");
lgraph = connectLayers(lgraph,"leakyrelu_1","avgpool2d_2");
lgraph = connectLayers(lgraph,"leakyrelu_1","maxpool_2");
lgraph = connectLayers(lgraph,"avgpool2d_2","multiplication_2/in1");
lgraph = connectLayers(lgraph,"maxpool_2","multiplication_2/in2");
0 comments on commit b93ff1d
2 个评论
Tian,HCong
2024-5-27
Hello, have you resolved your problem now? I am also very interested in this problem.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Call Python from MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!