bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
bitrl::rl::algos::es::MLPPolicy Class Reference

A small neural network whose weights are a flat vector of parameters, for EvolutionStrategy. More...

#include <mlp_policy.h>

Public Member Functions

 MLPPolicy (std::vector< uint_t > layer_sizes)
uint_t n_parameters () const noexcept
 How many parameters the network has.
const std::vector< uint_t > & layer_sizes () const noexcept
std::vector< real_t > initial_parameters (uint_t seed) const
 Weights drawn from N(0, 1 / fan_in), biases 0.
std::vector< real_t > forward (const std::vector< real_t > &parameters, const std::vector< real_t > &x) const
 The outputs of the network for observation x with parameters.
uint_t act_discrete (const std::vector< real_t > &parameters, const std::vector< real_t > &x) const
 The output with the largest value: the action of a discrete action space.
std::vector< real_t > act_continuous (const std::vector< real_t > &parameters, const std::vector< real_t > &x, real_t scale=1.0) const
 scale * tanh(outputs): the action of a bounded continuous action space

Detailed Description

A small neural network whose weights are a flat vector of parameters, for EvolutionStrategy.

The layers have the sizes given, the first the size of the observation and the last the number of outputs; the hidden layers use tanh, and the outputs are linear. The network holds no weights: every call takes them, so one MLPPolicy serves every candidate of a generation, on every thread at once. It needs no libtorch.

The parameters are, layer after layer, the weights row by row (an output's weights over the inputs) and then the biases.

Constructor & Destructor Documentation

◆ MLPPolicy()

bitrl::rl::algos::es::MLPPolicy::MLPPolicy ( std::vector< uint_t > layer_sizes)
inlineexplicit

Member Function Documentation

◆ act_continuous()

std::vector< real_t > bitrl::rl::algos::es::MLPPolicy::act_continuous ( const std::vector< real_t > & parameters,
const std::vector< real_t > & x,
real_t scale = 1.0 ) const
inline

scale * tanh(outputs): the action of a bounded continuous action space

◆ act_discrete()

uint_t bitrl::rl::algos::es::MLPPolicy::act_discrete ( const std::vector< real_t > & parameters,
const std::vector< real_t > & x ) const
inline

The output with the largest value: the action of a discrete action space.

◆ forward()

std::vector< real_t > bitrl::rl::algos::es::MLPPolicy::forward ( const std::vector< real_t > & parameters,
const std::vector< real_t > & x ) const
inline

The outputs of the network for observation x with parameters.

◆ initial_parameters()

std::vector< real_t > bitrl::rl::algos::es::MLPPolicy::initial_parameters ( uint_t seed) const
inline

Weights drawn from N(0, 1 / fan_in), biases 0.

◆ layer_sizes()

const std::vector< uint_t > & bitrl::rl::algos::es::MLPPolicy::layer_sizes ( ) const
inlinenoexcept

◆ n_parameters()

uint_t bitrl::rl::algos::es::MLPPolicy::n_parameters ( ) const
inlinenoexcept

How many parameters the network has.


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