0
$\begingroup$

I try to understand how getting an actions probability table instead of an unique prediction in stable baselines 3 SAC in order to override 'predict' method to filter invalid actions. I guess the good way to do that is to remove invalid actions from table and resize probabilities.

Models predictions can be deterministic or not but i can't find any function that returns action probabilities table (such function was available in SB2 if i remember well...)

I read these topics but they are not about SAC :

https://github.com/DLR-RM/stable-baselines3/issues/1347

https://github.com/DLR-RM/stable-baselines3/issues/568

https://github.com/DLR-RM/stable-baselines3/issues/385

Best regards.

$\endgroup$

1 Answer 1

0
$\begingroup$

Convert your observation to a tensor of the right shape if it is not already

obs_tensor = torch.tensor(obs.reshape((1,-1)), dtype=torch.float32)

with torch.no_grad():
    distribution = model.policy.get_distribution(obs_tensor)

The distribution object has logits and probs attributes:

print(distribution.distribution.probs)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.