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

Method _make_layer

lesson6-Segmentation/ResNet.cpp:128–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126}
127
128torch::nn::Sequential ResNetImpl::_make_layer(int64_t planes, int64_t blocks, int64_t stride) {
129
130 torch::nn::Sequential downsample;
131 if (stride != 1 || inplanes != planes * expansion) {
132 downsample = torch::nn::Sequential(
133 torch::nn::Conv2d(conv_options(inplanes, planes * expansion, 1, stride, 0, 1, false)),
134 torch::nn::BatchNorm2d(planes * expansion)
135 );
136 }
137 torch::nn::Sequential layers;
138 layers->push_back(Block(inplanes, planes, stride, downsample, groups, base_width, is_basic));
139 inplanes = planes * expansion;
140 for (int64_t i = 1; i < blocks; i++) {
141 layers->push_back(Block(inplanes, planes, 1, torch::nn::Sequential(), groups, base_width,is_basic));
142 }
143
144 return layers;
145}
146
147void ResNetImpl::make_dilated(std::vector<int> stage_list, std::vector<int> dilation_list) {
148 if (stage_list.size() != dilation_list.size()) {

Callers

nothing calls this directly

Calls 2

push_backMethod · 0.80
conv_optionsFunction · 0.70

Tested by

no test coverage detected