[Question] How to get value estimates in play.py script for rl_games? #3029
Replies: 1 comment
-
Thanks for posting this. In rl_games, the typical interface for action selection you’re using is: actions = agent.get_action(obs, is_deterministic=agent.is_deterministic) However, rl_games does not expose a direct method like How to Get Value Estimates from a Trained rl_games Agent1. Understanding the Architecture
2. Accessing the Value Function ManuallyIf you need value estimates, you can do so by directly accessing the appropriate function of the model. In rl_games, the agent wrapper usually stores the PyTorch policy network (often in Suppose your policy is loaded and you have an observation tensor (properly normalized and placed on the correct device): with torch.no_grad():
# Get both action and value estimate
action, value = agent.model.forward(obs)
# action is your policy output, value is the state value estimate
with torch.no_grad():
value = agent.model.a2c_network.get_value(obs)
3. Example with Isaac Lab IntegrationWhen you’re using Isaac Lab or a custom vectorized environment:
import torch
obs = ... # Your (batched) observation tensor
with torch.no_grad():
# PPO's a2c_network usually provides get_value
value = agent.model.a2c_network.get_value(obs) # shape: [num_envs, 1] 4. Important Notes
I'll move this post to our Discussions for follow up. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Question
Hello, I have trained a task using rl_games. I can the actions are obtained "actions = agent.get_action(obs, is_deterministic=agent.is_deterministic)" . How do I get value estimates? I need it for further analysis. I don't see a similar method for getting values.
Beta Was this translation helpful? Give feedback.
All reactions