Was the suggested workaround also not working? (Use var.detach().numpy() instead.)
For a more general approach, I would recommend to store the wanted activation in a list or dict by using forward hooks as described here.
Was the suggested workaround also not working? (Use var.detach().numpy() instead.)
For a more general approach, I would recommend to store the wanted activation in a list or dict by using forward hooks as described here.