eleurent / rl-agents

Implementations of Reinforcement Learning and Planning algorithms
MIT License
582 stars 152 forks source link

Log: agent statistics #90

Closed siddahant closed 1 year ago

siddahant commented 1 year ago

Is there any method to log the agent statistics i.e collision, agent speed, travel distance, lane change, etc?

eleurent commented 1 year ago

Hi, No, as of now there is unfortunately no method for that.

After every environment step, you can read the info field which contains some of these features (collision, agent speed...), but the other features (travel distance, lane changes) and statistics aggregations still need to be implemented.

PatrickYanZ commented 1 year ago

Hi @eleurent Is it possible to log the info to Callback like https://stable-baselines3.readthedocs.io/en/master/guide/callbacks.html to access some specific info in the Tensorboard.

By default, we can only see the logger log episodes and score only for HighwayEnv.

Or in the evaluation, can we log the info for each step on each episode? It is much better than I can get the data to compute average_score in one episode.

Thanks,

eleurent commented 1 year ago

Hey, I agree that this would be a nice feature. I guess the simplest thing we could do would be to pass the Evaluation a callback_fn which would take the e.g. env, agent, writer, and step_result=(obs,reward,terminal,truncated,info) as arguments, and which would be called after every step. And the user could implement whatever callback they want, such as [writer.add_scalar(k, v) for k, v in step_result.info.items()]