Explicitly obtain gradients?

params = list(network.parameters())

params will be a list of nn.Parameter objects, which are a subclass of Variable.
Each object in params will have a .grad attribute containing the gradients.

For example:

params[0].grad # gradient of first module's first weight.
8 Likes