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

Method DecoderBlockImpl

lesson6-Segmentation/UNetDecoder.cpp:34–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32}
33
34DecoderBlockImpl::DecoderBlockImpl(int in_channels, int skip_channels, int out_channels, bool skip, bool attention){
35 conv1 = Conv2dReLU(in_channels + skip_channels, out_channels, 3, 1);
36 conv2 = Conv2dReLU(out_channels, out_channels, 3, 1);
37 register_module("conv1", conv1);
38 register_module("conv2", conv2);
39 upsample = torch::nn::Upsample(torch::nn::UpsampleOptions().scale_factor(std::vector<double>({2,2})).mode(torch::kNearest));
40
41 attention1 = SCSEModule(in_channels + skip_channels, 16, attention);
42 attention2 = SCSEModule(out_channels, 16, attention);
43 register_module("attention1", attention1);
44 register_module("attention2", attention2);
45 is_skip = skip;
46}
47
48torch::Tensor DecoderBlockImpl::forward(torch::Tensor x, torch::Tensor skip){
49 x = upsample->forward(x);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected