Hello, may I consult about the difference in the effects of tensor.data.clone()
and tensor.data.detach().clone()
?
My goal is to interpolate between two parameters (of two models, respectively) and then assign the result to a new parameter (of a new model). My attempt is
new_param.data = 0.1 * old_param_1.data.clone() + 0.9 * old_param_2.data.clone()
I expect that new_param
has no history of operations or gradients of the old parameters, and the modification of the new parameter or old parameters does not affect each other. Is my attempt correct?
Additionally, what if I do
new_param.data = 0.1 * old_param_1.data.detach().clone() + 0.9 * old_param_2.data.detach().clone()
?
Is it necessary to add .detach()
?
Thank you in advance!