8 #ifndef BLACKCAT_TENSORS_NEURALNETWORKS_OPTIMIZERS_ADAM_H_ 9 #define BLACKCAT_TENSORS_NEURALNETWORKS_OPTIMIZERS_ADAM_H_ 18 template<
class Tensor>
24 template<
class Tensor>
39 template<
class... Args>
41 m_t(std::
forward<Args>(args)...),
42 v_t(std::
forward<Args>(args)...) {
48 template<
class TensorX,
class Gradients>
49 void update(TensorX& tensor, Gradients&& delta)
52 m_t = beta_1 * m_t + (1-beta_1) * delta;
53 v_t = beta_2 * v_t + (1-beta_2) *
bc::pow2(delta);
55 auto m_cap = m_t/(1-(
bc::pow(beta_1, time_stamp)));
56 auto v_cap = v_t/(1-(
bc::pow(beta_2, time_stamp)));
58 tensor += (alpha*m_cap)/(
bc::sqrt(v_cap)+epsilon);
self_type & zero()
Definition: tensor_base.h:13
void load(Layer_Loader &loader, std::string name)
Definition: adam.h:70
void save(Layer_Loader &loader, std::string name) const
Definition: adam.h:66
Definition: layer_loader.h:19
void set_learning_rate(value_type lr)
Definition: adam.h:62
typename parent_type::value_type value_type
Definition: tensor_base.h:41
typename Tensor::value_type value_type
Definition: adam.h:27
struct bc::oper::cmath_functions::Sqrt sqrt
Optimizer(Args &&... args)
Definition: adam.h:40
typename Tensor::system_tag system_tag
Definition: adam.h:28
Definition: optimizer_base.h:16
Tensor m_t
Definition: adam.h:36
struct bc::oper::cmath_functions::Pow pow
void update(TensorX &tensor, Gradients &&delta)
Definition: adam.h:49
Tensor v_t
Definition: adam.h:37
typename parent_type::system_tag system_tag
Definition: tensor_base.h:42
The Evaluator determines if an expression needs to be greedily optimized.
Definition: algorithms.h:22
struct bc::oper::cmath_functions::Pow2 pow2