/usr/local/lib64/python3.6/site-packages/torch/include/caffe2/sgd
NameSizeModeActions
adadelta_op.h58520644editdlrm
adagrad_fused.h166320644editdlrm
adagrad_op.h179930644editdlrm
adam_op.h261650644editdlrm
clip_tensor_op.h18530644editdlrm
decay_adagrad_op.h32150644editdlrm
fp16_momentum_sgd_op.h22920644editdlrm
fp32_momentum_sgd_op.h20150644editdlrm
ftrl_op.h22190644editdlrm
gftrl_op.h10280644editdlrm
iter_op.h33790644editdlrm
lars_op.h24790644editdlrm
learning_rate_adaption_op.h19740644editdlrm
learning_rate_functors.h151350644editdlrm
learning_rate_op.h126960644editdlrm
math_lp.h6550644editdlrm
momentum_sgd_op.h60350644editdlrm
rmsprop_op.h19800644editdlrm
rowwise_adagrad_fused.h295950644editdlrm
rowwise_counter.h20830644editdlrm
storm_op.h59150644editdlrm
weight_scale_op.h25520644editdlrm
wngrad_op.h72720644editdlrm
yellowfin_op.h102840644editdlrm
Edit: /usr/local/lib64/python3.6/site-packages/torch/include/caffe2/sgd/learning_rate_adaption_op.h (1974B)
#pragma once #include #include #include "caffe2/core/context.h" #include "caffe2/core/operator.h" #include "caffe2/utils/math.h" namespace caffe2 { template void lr_update( int n, const float* grad, const float* effgrad, const float* lr, float* nlr, float lr_alpha, bool normalized_lr_adaption, Context* /*context*/) { float x = 0; float y = 0, z = 0; const float kEps = 1e-12f; for (auto i = 0; i < n; i++) { x += grad[i] * effgrad[i]; if (normalized_lr_adaption) { y += grad[i] * grad[i]; z += effgrad[i] * effgrad[i]; } } if (normalized_lr_adaption) { y = fmax(std::sqrt(y), kEps); z = fmax(std::sqrt(z), kEps); nlr[0] = lr[0] * (1 - lr_alpha * x / (y * z)); } else { nlr[0] = lr[0] - lr_alpha * x; } } template class LearningRateAdaptionOp final : public Operator { public: LearningRateAdaptionOp(const OperatorDef& operator_def, Workspace* ws) : Operator(operator_def, ws), lr_alpha_(this->template GetSingleArgument("lr_alpha", 0.01f)), normalized_lr_adaption_(this->template GetSingleArgument( "normalized_lr_adaption", true)) {} USE_OPERATOR_CONTEXT_FUNCTIONS; bool RunOnDevice() override { CAFFE_ENFORCE(Input(LR).numel() == 1); CAFFE_ENFORCE(Input(GRAD).numel() == Input(EFFGRAD).numel()); Output(OUTPUT_LR)->ResizeLike(Input(LR)); lr_update( Input(GRAD).numel(), Input(GRAD).template data(), Input(EFFGRAD).template data(), Input(LR).template data(), Output(OUTPUT_LR)->template mutable_data(), lr_alpha_, normalized_lr_adaption_, &context_); return true; } protected: T lr_alpha_{1e-2}; bool normalized_lr_adaption_{true}; INPUT_TAGS(LR, GRAD, EFFGRAD); OUTPUT_TAGS(OUTPUT_LR); }; } // namespace caffe2