thu-ml / tianshou

An elegant PyTorch deep reinforcement learning library.
https://tianshou.org
MIT License
7.83k stars 1.12k forks source link

Collector for safety-gym cost key entry? #363

Closed drozzy closed 3 years ago

drozzy commented 3 years ago

Hi, I'm curious how I would implement the tracking of the additional metric cost (which is implemented in safety-gym environments.

Basically it is contained inside the info['cost'] objects. Right now collectors in tianshou discard the info dict, and only return a predetermined set of metrics: https://github.com/thu-ml/tianshou/blob/84f58636eb3895413c82cc3a991bf0f0e5b043ad/tianshou/data/collector.py#L159

Would it be possible to extend it to be a bit more general or should I write a new collector class for my needs?

Thank you.

Trinkle23897 commented 3 years ago

See https://tianshou.readthedocs.io/en/master/tutorials/cheatsheet.html#handle-batched-data-stream-in-collector

drozzy commented 3 years ago

Thank you I'll give it a go.