Initializing a differentiable param in pytorch
I'm trying to define a set of new parameters B in a pytorch model. I would like to initialize the new params with current weights of the model W.
Question: I want these params B to be differentiable, but autograd should not track their history to W (so B should have a new memory with no reference to W). What is the correct function to use?
I understand B = W.clone() will result in autograd tracking history of B to W while differentiating. Also I understand that B = W.detach().clone() will not be differentiable.

EDIT:
I believe B = nn.Parameter(W.detach().clone()) should be the correct function. Is this correct and if yes, is this the simplest function to use?

There are several ways to do it and one of them is
B = W.clone().detach()

Another elegant one comes to my mind is
B = torch.new_tensor(x, requires_grad=True)

which is much more readable and the doc says they are equivalent.
If you want it as a parameter to nn.Module, of course wrap it with
self.B = nn.Parameter(...)

