mxnet
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
mxnet::cpp::Optimizer Class Referenceabstract

Optimizer interface. More...

#include <optimizer.h>

Inheritance diagram for mxnet::cpp::Optimizer:
Inheritance graph
Collaboration diagram for mxnet::cpp::Optimizer:
Collaboration graph

Public Member Functions

 Optimizer (unsigned begin_num_update)
 constructor More...
 
virtual std::string GetType () const =0
 get optimizer type More...
 
virtual ~Optimizer ()
 destructor More...
 
template<typename T >
OptimizerSetParam (const std::string &name, const T &value)
 set config parameters More...
 
OptimizerSetLRScheduler (std::unique_ptr< LRScheduler > lrScheduler)
 
virtual void Update (int index, NDArray weight, NDArray grad)=0
 Update a weight with gradient. More...
 
std::string Serialize () const
 Serialize the optimizer parameters to a string. More...
 

Protected Member Functions

const std::vector< const char * > GetParamKeys_ () const
 
const std::vector< const char * > GetParamValues_ () const
 
unsigned UpdateCount_ (int index)
 
float GetLR_ (int index)
 
float GetWD_ (int index)
 
virtual void CreateState_ (int index, NDArray weight)
 

Static Protected Member Functions

static OpMap *& op_map ()
 

Protected Attributes

std::map< std::string, std::string > params_
 
std::map< int, unsigned > count_
 
unsigned begin_num_update_
 
unsigned num_update_
 
std::unique_ptr< LRSchedulerlrScheduler_ = nullptr
 

Detailed Description

Optimizer interface.

Constructor & Destructor Documentation

mxnet::cpp::Optimizer::Optimizer ( unsigned  begin_num_update)
explicit

constructor

Parameters
beign_num_updateThe initial number of updates
virtual mxnet::cpp::Optimizer::~Optimizer ( )
virtual

destructor

Member Function Documentation

virtual void mxnet::cpp::Optimizer::CreateState_ ( int  index,
NDArray  weight 
)
protectedvirtual
float mxnet::cpp::Optimizer::GetLR_ ( int  index)
protected
const std::vector<const char*> mxnet::cpp::Optimizer::GetParamKeys_ ( ) const
protected
const std::vector<const char*> mxnet::cpp::Optimizer::GetParamValues_ ( ) const
protected
virtual std::string mxnet::cpp::Optimizer::GetType ( ) const
pure virtual
float mxnet::cpp::Optimizer::GetWD_ ( int  index)
protected
static OpMap*& mxnet::cpp::Optimizer::op_map ( )
staticprotected
std::string mxnet::cpp::Optimizer::Serialize ( ) const

Serialize the optimizer parameters to a string.

Returns
serialization
Optimizer* mxnet::cpp::Optimizer::SetLRScheduler ( std::unique_ptr< LRScheduler lrScheduler)
inline

set the lr scheduler

Parameters
lrSchedulerlr scheduler used for this optimizer
Returns
reference if self
template<typename T >
Optimizer* mxnet::cpp::Optimizer::SetParam ( const std::string &  name,
const T &  value 
)
inline

set config parameters

Parameters
namename of the config parameter
valuevalue of the config parameter
Returns
reference of self
virtual void mxnet::cpp::Optimizer::Update ( int  index,
NDArray  weight,
NDArray  grad 
)
pure virtual

Update a weight with gradient.

Parameters
indexthe unique index for the weight.
weightthe weight to update.
gradgradient for the weight.

Implemented in mxnet::cpp::AdaDeltaOptimizer, mxnet::cpp::AdaGradOptimizer, mxnet::cpp::AdamOptimizer, mxnet::cpp::RMSPropOptimizer, and mxnet::cpp::SGDOptimizer.

unsigned mxnet::cpp::Optimizer::UpdateCount_ ( int  index)
protected

Member Data Documentation

unsigned mxnet::cpp::Optimizer::begin_num_update_
protected
std::map<int, unsigned> mxnet::cpp::Optimizer::count_
protected
std::unique_ptr<LRScheduler> mxnet::cpp::Optimizer::lrScheduler_ = nullptr
protected
unsigned mxnet::cpp::Optimizer::num_update_
protected
std::map<std::string, std::string> mxnet::cpp::Optimizer::params_
protected

The documentation for this class was generated from the following file: