| 842 | }; |
| 843 | |
| 844 | class pySGD : public py::class_<graphvite::SGD, graphvite::Optimizer> { |
| 845 | public: |
| 846 | typedef graphvite::SGD SGD; |
| 847 | typedef py::class_<SGD, graphvite::Optimizer> Base; |
| 848 | using Base::def; |
| 849 | using Base::def_readonly; |
| 850 | |
| 851 | template<class... Args> |
| 852 | pySGD(py::handle scope, const char *name, const Args &...args) : |
| 853 | Base(scope, name, args...) { |
| 854 | attr("__doc__") = "SGD(lr=1e-4, weight_decay=0, schedule='linear')" |
| 855 | R"( |
| 856 | Stochastic gradient descent optimizer. |
| 857 | |
| 858 | Parameters: |
| 859 | lr (float, optional): initial learning rate |
| 860 | weight_decay (float, optional): weight decay (L2 regularization) |
| 861 | schedule (str or callable, optional): learning rate schedule |
| 862 | )"; |
| 863 | |
| 864 | // member functions |
| 865 | def(py::init<float, float, graphvite::LRSchedule>(), py::no_gil(), |
| 866 | py::arg("lr") = 1e-4, py::arg("weight_decay") = 0, |
| 867 | py::arg("schedule") = "linear"); |
| 868 | } |
| 869 | }; |
| 870 | |
| 871 | class pyMomentum : public py::class_<graphvite::Momentum, graphvite::Optimizer> { |
| 872 | public: |
nothing calls this directly
no outgoing calls
no test coverage detected