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

Method VGGImpl

src/backbones/VGG.cpp:23–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21}
22
23VGGImpl::VGGImpl(std::vector<int> _cfg, int num_classes, bool batch_norm_) {
24 cfg = _cfg;
25 batch_norm = batch_norm_;
26 features_ = make_features(cfg, batch_norm);
27 avgpool = torch::nn::AdaptiveAvgPool2d(torch::nn::AdaptiveAvgPool2dOptions(7));
28 classifier->push_back(torch::nn::Linear(torch::nn::LinearOptions(512 * 7 * 7, 4096)));
29 classifier->push_back(torch::nn::ReLU(torch::nn::ReLUOptions(true)));
30 classifier->push_back(torch::nn::Dropout());
31 classifier->push_back(torch::nn::Linear(torch::nn::LinearOptions(4096, 4096)));
32 classifier->push_back(torch::nn::ReLU(torch::nn::ReLUOptions(true)));
33 classifier->push_back(torch::nn::Dropout());
34 classifier->push_back(torch::nn::Linear(torch::nn::LinearOptions(4096, num_classes)));
35
36 features_ = register_module("features", features_);
37 classifier = register_module("classifier", classifier);
38}
39
40torch::Tensor VGGImpl::forward(torch::Tensor x) {
41 x = features_->forward(x);

Callers

nothing calls this directly

Calls 2

make_featuresFunction · 0.85
push_backMethod · 0.80

Tested by

no test coverage detected