E1 · Your training
3 minRun curvas.py on the lesson 5 training and write down the term that paid the most at the end.
Done when: python3 kit/curvas.py $F/treino/ppo; echo "saída: $?" → treino: ppo · 20 iterações and saída: 0.
Lesson 6 · 16 min
A reward curve going up does not mean the robot learned to walk. In this lesson you read the log of your own training and of two real 150-iteration trainings, recorded for the course: in one of them the reward goes up because the robot learned to fall sooner. The other shows the fix and the limit of the fix.
Start the lesson
Goal: read the log of a training run and recognize collapse and reward hacking.
Click each block. Each alert compares the first and the last quarter of the training.
Walking on its knees, shaking, and standing still are the classic shortcuts. All of them show up when you read these four numbers together, never the reward alone.
The progresso.csv from lesson 5.
F=${FTH:-$HOME/fth}; cd $F/locomocao && . $F/.venv/bin/activate
python3 kit/curvas.py $F/treino/ppo; echo "saída: $?"treino: ppo · 20 iterações (médias do primeiro e do último quarto) recompensa inicial: -3.64 · final: -4.75 episódio médio: 46 → 58 passos (de 1000) velocidade para a frente no fim: 0.14 m/s · termo que mais pagou no fim: pose (1.00) alertas: 0 saída: 0
In 20 iterations the reward still oscillates and the term that pays the most is pose: the policy has barely left the default pose. No alerts, but nothing to learn from either. That is why the kit includes two larger training runs. Careful: curvas.py exits 0 even with an alert; read the alertas: line, not the exit code.
Generated with the same kit/treinar.py, 32 environments, seed 0. cai-cedo uses kit/recompensa.yaml (8 min); com-vivo adds the is_alive term with weight 5 (10 min). Only the progresso.csv is in the repository.
is_alive: {weight: 5.0} # 5 × 0,02 s = +0,1 por passo de pé: ficar vivo passa a valer mais que a puniçãoF=${FTH:-$HOME/fth}; cd $F/locomocao && . $F/.venv/bin/activate
for x in cai-cedo com-vivo; do python3 kit/curvas.py kit/exemplos/$x; echo; donetreino: cai-cedo · 150 iterações (médias do primeiro e do último quarto) recompensa inicial: -4.31 · final: -1.12 episódio médio: 55 → 15 passos (de 1000) velocidade para a frente no fim: 0.15 m/s · termo que mais pagou no fim: upright (0.23) ALERTA: recompensa hackeada: a recompensa subiu porque o episódio encurtou; cada passo de pé custa mais do que paga, e cair cedo virou a melhor estratégia alertas: 1 treino: com-vivo · 150 iterações (médias do primeiro e do último quarto) recompensa inicial: 1.36 · final: 2.32 episódio médio: 57 → 63 passos (de 1000) velocidade para a frente no fim: 0.16 m/s · termo que mais pagou no fim: is_alive (6.27) alertas: 0
cai-cedo: the reward rose from −4.31 to −1.12 while the episode dropped from 55 to 15 steps. Since every step spent standing had a negative balance (the penalty for abrupt actions outweighed the rewards), falling early became the best strategy.
com-vivo: with is_alive weight 5 (+0.1 per step standing, 5 per second), the episode starts to grow (57 → 63) and no alert fires. But the term that pays the most is is_alive and the speed is 0.16 m/s: the training learned not to fall, not yet to walk.
Run it, watch the curve reading stop the training, and run it again. This is the loop of this lesson.
Illustrative simulation in the browser. The alert in the curve reading is on purpose: it is the cai-cedo case.
Read before you believe.
Run curvas.py on the lesson 5 training and write down the term that paid the most at the end.
Done when: python3 kit/curvas.py $F/treino/ppo; echo "saída: $?" → treino: ppo · 20 iterações and saída: 0.
Run both examples and write, in one sentence, why the reward in cai-cedo went up.
Done when: the cai-cedo output shows ALERTA: recompensa hackeada and alertas: 1; your sentence mentions the episode getting shorter (55 → 15 steps).
The com-vivo doesn't fall, but it walks at 0.16 m/s. Propose a tweak to one term (which one, old weight, new weight) and say what signal you would expect to see in the curves if it works.
Done when: you wrote one term from kit/recompensa.yaml with both weights and a measurable signal (e.g., final speed above 0.3 m/s without the episode getting shorter).
The explanation appears after your answer.
Question 1 of 4
In cai-cedo, the reward went up and the episode dropped from 55 to 15 steps. What did the policy learn?skill
Question 2 of 4
The com-vivo triggers no alert. Why is it still not a good training run?
Question 3 of 4
Which reading detects "reward hacking" most reliably?
Question 4 of 4
Why does the kit keep two example training runs instead of asking you to run 150 iterations?
Choose an option. The explanation appears after you try.