NVlabs / DiffRL

[ICLR 2022] Accelerated Policy Learning with Parallel Differentiable Simulation
https://short-horizon-actor-critic.github.io/
Other
263 stars 43 forks source link

Obtain gradient information explicitly #13

Closed glue25 closed 1 year ago

glue25 commented 1 year ago

May I ask how to explicitly obtain gradient information in the environment, such as obtaining the gradient of s_{t+1} to s_t? Or is the information obtained using torch.autograd accurate? Thank you!

eanswer commented 1 year ago

Although it's not tested, since dflex is built upon PyTorch, you should be able to use PyTorch functions to get jacobian info. To be noted, the backward gradients are computed via reverse mode auto differentiation like PyTorch, so the intermediate jacobians are not explicitly computed, which means you may only get the jacobian from output to input (i.e. call s_{s+1} = step(st) then use PyTorch function to get d(s{t+1})/d(s_{t}).