Caffe2 - C++ API
A deep learning, cross platform ML framework
Public Member Functions | Protected Member Functions | Protected Attributes
torch::optim::detail::OptimizerBase Class Reference

Base class for all optimizers, that does not yet define a step() mechanism. More...

#include <optimizer.h>

Inheritance diagram for torch::optim::detail::OptimizerBase:
torch::optim::LossClosureOptimizer torch::optim::Optimizer torch::optim::LBFGS torch::optim::Adagrad torch::optim::Adam torch::optim::RMSprop torch::optim::SGD

Public Member Functions

 OptimizerBase (std::vector< Tensor > parameters)
 Constructs the Optimizer from a vector of parameters.
 
void add_parameters (const std::vector< Tensor > &parameters)
 Adds the given vector of parameters to the optimizer's parameter list.
 
virtual void zero_grad ()
 Zeros out the gradients of all parameters.
 
const std::vector< Tensor > & parameters () const noexcept
 Provides a const reference to the parameters this optimizer holds.
 
std::vector< Tensor > & parameters () noexcept
 Provides a reference to the parameters this optimizer holds.
 
size_t size () const noexcept
 Returns the number of parameters referenced by the optimizer.
 
virtual void save (serialize::OutputArchive &archive) const
 Serializes the optimizer state into the given archive.
 
virtual void load (serialize::InputArchive &archive)
 Deserializes the optimizer state from the given archive.
 

Protected Member Functions

template<typename T >
Tbuffer_at (std::vector< T > &buffers, size_t index)
 Accesses a buffer at the given index. More...
 
Tensorbuffer_at (std::vector< Tensor > &buffers, size_t index)
 Accesses a buffer at the given index, converts it to the type of the parameter at the corresponding index (a no-op if they match). More...
 

Protected Attributes

std::vector< Tensorparameters_
 The parameters this optimizer optimizes.
 

Detailed Description

Base class for all optimizers, that does not yet define a step() mechanism.

All it specifies is that optimizers must be supplied with a vector of parameters. It also defines certain methods that all optimizers shall have, such as zero_grad.

Definition at line 34 of file optimizer.h.

Member Function Documentation

template<typename T >
T& torch::optim::detail::OptimizerBase::buffer_at ( std::vector< T > &  buffers,
size_t  index 
)
inlineprotected

Accesses a buffer at the given index.

Additionally, zeros out the buffers when this is called on the index

Definition at line 68 of file optimizer.h.

Tensor & torch::optim::detail::OptimizerBase::buffer_at ( std::vector< Tensor > &  buffers,
size_t  index 
)
protected

Accesses a buffer at the given index, converts it to the type of the parameter at the corresponding index (a no-op if they match).

Additionally, zeros out the buffers when this is called on the index

Definition at line 43 of file optimizer.cpp.


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