| 67 | namespace MNN { |
| 68 | namespace Train { |
| 69 | ParameterOptimizer::ParameterOptimizer(std::shared_ptr<Module> module) { |
| 70 | mModule = module; |
| 71 | if (nullptr == mModule) { |
| 72 | mModule.reset(Module::createEmpty(std::vector<MNN::Express::VARP>{})); |
| 73 | } |
| 74 | auto parameters = mModule->parameters(); |
| 75 | for (auto p : parameters) { |
| 76 | if (nullptr == p.get()) { |
| 77 | continue; |
| 78 | } |
| 79 | if (p->expr().first->get() != nullptr) { |
| 80 | continue; |
| 81 | } |
| 82 | if (p->expr().first->inputType() == Express::VARP::TRAINABLE) { |
| 83 | mTrainable.insert(p); |
| 84 | } |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | ParameterOptimizer* ParameterOptimizer::createSGD(std::shared_ptr<Module> module, float lr, float momentum, float weightDecay, RegularizationMethod method) { |
| 89 | auto sgd = new SGD(module); |
nothing calls this directly
no test coverage detected