This method uses the .data
attribute internally:
param.data = vec[pointer:pointer + num_param].view_as(param).data
and thus Autograd won’t capture this operation.
You could check if e.g. torch.nn.utils.parametrize
might work as described in this post.