Categorical distribution in LibTorch?


In python we can do

m = Categorical(probs)  <----
action = m.sample()

How can I sample from a given categorical distribution in libtorch? I’ve searched the docs but I can’t find any matching function in the C++ frontend. If it’s not implemented yet, what would be the most efficient way to sample that way for now? I could use std’s discrete_distribution, but seems a bit too much like a workaround

1 Like

bumping this…

(Bojacob) #4

Did you ever figure this out? I thought of porting the categorical distribution from Python but reading the Python source code makes me think this isn’t a trivial task.

(Afshin Oroojlooy) #5

Still no update on this?