MCPcopy Create free account
hub / github.com/AllentDan/LibtorchSegmentation / ASPPImpl

Method ASPPImpl

src/architectures/DeepLabDecoder.cpp:42–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40}
41
42ASPPImpl::ASPPImpl(int in_channels, int out_channels, std::vector<int> atrous_rates, bool separable) {
43 modules->push_back(torch::nn::Sequential(torch::nn::Conv2d(conv_options(in_channels, out_channels, 1, 1, 0, 1, false)),
44 torch::nn::BatchNorm2d(torch::nn::BatchNorm2dOptions(out_channels)),
45 torch::nn::ReLU()));
46 if (atrous_rates.size() != 3) std::cout<< "size of atrous_rates must be 3";
47 if (separable) {
48 modules->push_back(ASPPSeparableConv(in_channels, out_channels, atrous_rates[0]));
49 modules->push_back(ASPPSeparableConv(in_channels, out_channels, atrous_rates[1]));
50 modules->push_back(ASPPSeparableConv(in_channels, out_channels, atrous_rates[2]));
51 }
52 else {
53 modules->push_back(ASPPConv(in_channels, out_channels, atrous_rates[0]));
54 modules->push_back(ASPPConv(in_channels, out_channels, atrous_rates[1]));
55 modules->push_back(ASPPConv(in_channels, out_channels, atrous_rates[2]));
56 }
57 aspppooling = ASPPPooling(in_channels, out_channels);
58
59 project = torch::nn::Sequential(
60 torch::nn::Conv2d(conv_options(5 * out_channels, out_channels, 1, 1, 0, 1, false)),
61 torch::nn::BatchNorm2d(torch::nn::BatchNorm2dOptions(out_channels)),
62 torch::nn::ReLU(),
63 torch::nn::Dropout(torch::nn::DropoutOptions(0.5)));
64
65 register_module("modules", modules);
66 register_module("aspppooling", aspppooling);
67 register_module("project", project);
68}
69
70torch::Tensor ASPPImpl::forward(torch::Tensor x) {
71 std::vector<torch::Tensor> res;

Callers

nothing calls this directly

Calls 5

conv_optionsFunction · 0.85
ASPPSeparableConvFunction · 0.85
ASPPConvFunction · 0.85
push_backMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected