Hi Charlie!



 charlieparker:

The problem is after this the a is still 0.2 and if I call a.grad it is 0.


The is because that although torch.poisson() returns floating-point
numbers and attaches a grad_fn=<PoissonBackward> to the
computation graph, it gives, by design, zero gradients.
First is the question of what the derivative of a random sample
with respect to some distribution parameter ought to be.  Pytorch
chooses zero.  See the discussion of “gradient estimators” in the
torch.distributions 1 documentation.
Second is the fact that torch.poisson() returns values that are
discrete integers (even though they are packaged as floating-point
numbers).  Since the result of torch.poisson() is stuck at an integer,
it can’t change by “just a little bit,” so it makes sense to define its
derivative as zero.
Best.
K. Frank