A2C¶
Figure: A2C algorithm pseudocode 1
toyrl.a2c.default_config
module-attribute
¶
default_config = A2CConfig(env_name='CartPole-v1', render_mode=None, solved_threshold=475.0, num_episodes=100000, learning_rate=0.002, log_wandb=True)
toyrl.a2c.A2CConfig
dataclass
¶
A2CConfig(env_name: str = 'CartPole-v1', render_mode: str | None = None, solved_threshold: float = 475.0, gamma: float = 0.999, lambda_: float = 0.98, value_loss_coef: float = 0.5, policy_loss_coef: float = 0.5, entropy_coef: float = 0.01, num_episodes: int = 500, learning_rate: float = 0.01, eval_episodes: int = 10, eval_interval: int = 100, log_wandb: bool = False)
Configuration for A2C algorithm.
toyrl.a2c.ActorCriticNet
¶
Bases: Module
Source code in toyrl/a2c.py
37 38 39 40 41 42 43 44 45 46 |
|
forward
¶
forward(x: Tensor) -> tuple[Tensor, Tensor]
Source code in toyrl/a2c.py
48 49 50 51 52 |
|
toyrl.a2c.Experience
dataclass
¶
toyrl.a2c.ReplayBuffer
dataclass
¶
ReplayBuffer(buffer: list[Experience] = list())
__len__
¶
__len__() -> int
Source code in toyrl/a2c.py
69 70 |
|
add_experience
¶
add_experience(experience: Experience) -> None
Source code in toyrl/a2c.py
72 73 |
|
sample
¶
sample() -> list[Experience]
Source code in toyrl/a2c.py
78 79 |
|
toyrl.a2c.Agent
¶
Agent(net: Module, optimizer: Optimizer)
Source code in toyrl/a2c.py
86 87 88 89 |
|
onpolicy_reset
¶
onpolicy_reset() -> None
Source code in toyrl/a2c.py
91 92 |
|
add_experience
¶
add_experience(experience: Experience) -> None
Source code in toyrl/a2c.py
94 95 |
|
get_buffer_total_reward
¶
get_buffer_total_reward() -> float
Source code in toyrl/a2c.py
97 98 |
|
act
¶
Source code in toyrl/a2c.py
100 101 102 103 104 105 106 107 108 |
|
net_update
¶
net_update(gamma: float, lambda_: float, value_loss_coef: float, policy_loss_coef: float, entropy_coef: float) -> tuple[float, float, float]
Source code in toyrl/a2c.py
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 |
|
toyrl.a2c.A2CTrainer
¶
A2CTrainer(config: A2CConfig)
Source code in toyrl/a2c.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
|
train
¶
train() -> None
Source code in toyrl/a2c.py
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
|
evaluate
¶
Source code in toyrl/a2c.py
232 233 234 235 236 237 238 239 240 241 242 |
|
-
L. Graesser and W. L. Keng, Foundations of deep reinforcement learning: Theory and practice in python. Addison-Wesley Professional, 2019. ↩