How to implement stochastic pooling in pytorch?

I am trying to implement Stochastic pooling. But I am very much unclear about how to sample from a multi-nominal distribution to get the location from where we need to pool. Could you please provide any example code?

1 Like

Are you looking for this?


Thank you very much for the implementation. Do you think the run time of this can be somehow improved, for e.g. by somehow replacing the for loop?

1 Like

Hi, In the stochastic pooling, the author used probabilistic weighting at test time. I tried that, but the testing is not performing well. Did you have any solution for that?

Hi, @smani @Nirthika_Rajendran
Sorry I haven’t studied this code carefully. I just happened to see it before, so I shared it. :worried: