I am trying to port a Q-network, and it uses probability distribution sampling (Normal class in Python and its rsample function). Are these available in PyTorch C++?
I am trying to port a Q-network, and it uses probability distribution sampling (Normal class in Python and its rsample function). Are these available in PyTorch C++?
As of now, there is not yet a frontend for distributions in libtorch (you can check the Namespaces here).
Apparently it's on the roadmap for a future update according to this thread.
There are links to the internal C++ implementations of distributions in that thread as well.
The normal distribution is kinda available in the C++ frontend with the torch::randn (normal distribution, mean=0 and deviation=1) function, though it does not indeed provide the rsample functionnality. You will have to implemented the reparameterization trick yourself, but that should not take more than a couple lines of code.