4 #include <torch/nn/module.h> 5 #include <torch/optim/optimizer.h> 6 #include <torch/optim/serialize.h> 23 TORCH_ARG(
double, learning_rate);
24 TORCH_ARG(
double, beta1) = 0.9;
25 TORCH_ARG(
double, beta2) = 0.999;
26 TORCH_ARG(
double, weight_decay) = 0;
27 TORCH_ARG(
double, eps) = 1e-8;
28 TORCH_ARG(
bool, amsgrad) =
false;
33 template <
typename ParameterContainer>
34 explicit Adam(ParameterContainer&& parameters,
const AdamOptions& options)
35 :
Optimizer(std::forward<ParameterContainer>(parameters)),
45 std::vector<int64_t> step_buffers;
46 std::vector<Tensor> exp_average_buffers;
47 std::vector<Tensor> exp_average_sq_buffers;
48 std::vector<Tensor> max_exp_average_sq_buffers;
51 Adam() : options(0) {}
53 template <
typename Self,
typename Archive>
54 static void serialize(Self&
self, Archive& archive) {
55 _TORCH_OPTIM_SERIALIZE(step_buffers);
56 _TORCH_OPTIM_SERIALIZE(exp_average_buffers);
57 _TORCH_OPTIM_SERIALIZE(exp_average_sq_buffers);
58 _TORCH_OPTIM_SERIALIZE(max_exp_average_sq_buffers);
Optimizer that defines a required step() method that takes no arguments and produces no values...