bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
reinforce_loss.h
Go to the documentation of this file.
1#ifndef REINFORCE_LOSS_H
2#define REINFORCE_LOSS_H
3
4#include "bitrl/base/bitrl_config.h"
5
6#ifdef USE_PYTORCH
7
10
11#include <vector>
12
13namespace bitrl
14{
15namespace rl
16{
17namespace algos
18{
19namespace pg
20{
21
22// using namespace bitsim::consts;
23
27std::vector<torch_tensor_t> compute_loss_item(const std::vector<real_t> &rewards,
28 const std::vector<torch_tensor_t> &log_probs);
29
34std::vector<real_t> compute_baseline_with_constant(const std::vector<real_t> &rewards,
35 real_t constant);
36
41std::vector<real_t> compute_baseline_with_mean(const std::vector<real_t> &rewards);
42
47std::vector<real_t> compute_baseline_with_standardization(const std::vector<real_t> &rewards,
49
50} // namespace pg
51} // namespace algos
52} // namespace rl
53} // namespace bitrl
54
55#endif
56#endif
Definition a2c.h:37
std::vector< real_t > compute_baseline_with_mean(const std::vector< real_t > &rewards)
Compute the baseline using the mean value of the provided rewards.
std::vector< real_t > compute_baseline_with_standardization(const std::vector< real_t > &rewards, real_t eps=bitsim::consts::TOLERANCE)
Compute the baseline using standarization also known as whitening.
std::vector< torch_tensor_t > compute_loss_item(const std::vector< real_t > &rewards, const std::vector< torch_tensor_t > &log_probs)
compute_loss_item. Compute the product -rewards[i] * log_probs[i]
std::vector< real_t > compute_baseline_with_constant(const std::vector< real_t > &rewards, real_t constant)
Compute the baseline using a user-defined constant value from the given rewards.
Definition dp_algo_base.h:15
Definition dummy_agent.h:9
Various utilities used when working with RL problems.
Definition bitrl_log.h:25
const real_t TOLERANCE
Tolerance used around the library.
Definition bitsim_consts.h:26
double real_t
real_t
Definition bitsim_types.h:20