(model: art.TrainableModel)
| 114 | |
| 115 | |
| 116 | async def train_model(model: art.TrainableModel): |
| 117 | train_iterator = iterate_dataset( |
| 118 | training_tasks, |
| 119 | groups_per_step=4, |
| 120 | initial_step=await model.get_step(), |
| 121 | ) |
| 122 | |
| 123 | for batch in train_iterator: |
| 124 | groups = await art.gather_trajectory_groups( |
| 125 | art.TrajectoryGroup( |
| 126 | (rollout(model, scenario) for _ in range(6)), |
| 127 | ) |
| 128 | for scenario in batch.items |
| 129 | ) |
| 130 | result = await backend.train(model, groups) |
| 131 | await model.log(groups, metrics=result.metrics, step=result.step, split="train") |
| 132 | |
| 133 | if batch.step % 20 == 0: |
| 134 | # Every 20 steps let's benchmark our model under training so we can |
| 135 | # see how it's doing. |
| 136 | await benchmark_model(model) |
| 137 | |
| 138 | # At the end of training, let's benchmark the model again to see where it |
| 139 | # ended up. |
| 140 | await benchmark_model(model) |
| 141 | |
| 142 | |
| 143 | async def main(): |
no test coverage detected