| 21 | } |
| 22 | |
| 23 | VGGImpl::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 | |
| 38 | torch::Tensor VGGImpl::forward(torch::Tensor x){ |
| 39 | x = features_->forward(x); |
nothing calls this directly
no test coverage detected