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

Method VGGImpl

lesson5-TrainingVGG/vgg.cpp:23–36  ·  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 features_ = make_features(cfg,batch_norm);
25 avgpool = torch::nn::AdaptiveAvgPool2d(torch::nn::AdaptiveAvgPool2dOptions(7));
26 classifier->push_back(torch::nn::Linear(torch::nn::LinearOptions(512 * 7 * 7, 4096)));
27 classifier->push_back(torch::nn::ReLU(torch::nn::ReLUOptions(true)));
28 classifier->push_back(torch::nn::Dropout());
29 classifier->push_back(torch::nn::Linear(torch::nn::LinearOptions(4096, 4096)));
30 classifier->push_back(torch::nn::ReLU(torch::nn::ReLUOptions(true)));
31 classifier->push_back(torch::nn::Dropout());
32 classifier->push_back(torch::nn::Linear(torch::nn::LinearOptions(4096, num_classes)));
33
34 features_ = register_module("features",features_);
35 classifier = register_module("classifier",classifier);
36}
37
38torch::Tensor VGGImpl::forward(torch::Tensor x){
39 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