MCPcopy Create free account
hub / github.com/AllentDan/LibtorchTutorials / SCSEModuleImpl

Method SCSEModuleImpl

lesson6-Segmentation/UNetDecoder.cpp:3–14  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1#include "UNetDecoder.h"
2
3SCSEModuleImpl::SCSEModuleImpl(int in_channels, int reduction, bool _use_attention){
4 use_attention = _use_attention;
5 cSE = torch::nn::Sequential(
6 torch::nn::AdaptiveAvgPool2d(torch::nn::AdaptiveAvgPool2dOptions(1)),
7 torch::nn::Conv2d(conv_options(in_channels, in_channels / reduction, 1)),
8 torch::nn::ReLU(torch::nn::ReLUOptions(true)),
9 torch::nn::Conv2d(conv_options(in_channels / reduction, in_channels, 1)),
10 torch::nn::Sigmoid());
11 sSE = torch::nn::Sequential(torch::nn::Conv2d(conv_options(in_channels, 1, 1)), torch::nn::Sigmoid());
12 register_module("cSE",cSE);
13 register_module("sSE",sSE);
14}
15
16torch::Tensor SCSEModuleImpl::forward(torch::Tensor x){
17 if(!use_attention) return x;

Callers

nothing calls this directly

Calls 1

conv_optionsFunction · 0.70

Tested by

no test coverage detected