swarmrl.losses.proximal_policy_loss Module API Reference¶
Loss functions based on Proximal policy optimization.
Notes¶
https://spinningup.openai.com/en/latest/algorithms/ppo.html
ProximalPolicyLoss
¶
Bases: Loss
, ABC
Class to implement the proximal policy loss.
Source code in swarmrl/losses/proximal_policy_loss.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
|
__init__(value_function=GAE(), sampling_strategy=GumbelDistribution(), n_epochs=20, epsilon=0.2, entropy_coefficient=0.01)
¶
Constructor for the PPO class.
Parameters¶
value_function : Callable A the state value function that computes the value of a series of states for using the reward of the trajectory visiting these states n_epochs : int number of PPO updates epsilon : float the maximum of the relative distance between old and updated policy. entropy_coefficient : float Entropy coefficient for the PPO update. # TODO Add more here.
Source code in swarmrl/losses/proximal_policy_loss.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
|
compute_loss(network, episode_data)
¶
Compute the loss and update the shared actor-critic network.
Parameters¶
network : Network actor-critic model to use in the analysis. episode_data : np.ndarray (n_timesteps, n_particles, feature_dimension) Observable data for each time step and particle within the episode.
Returns¶
Source code in swarmrl/losses/proximal_policy_loss.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
|