<p>Aside from @benjaminplanche 's answer, I'd use it to manually change values of parameters.</p>
<p>For instance, I have the following model:</p>
<pre><code>model = nn.Sequential(nn.Linear(10, 1))
</code></pre>
<p>and for some reason, I'd like to manually update the values of its parameters. Then, I can do:</p>
<pre><code>for param in model.parameters():
    param.data = 10 * param.data  # multiply the parameter values by 10.
</code></pre>
<p>Note that if we remove <code>.data</code> behind <code>param</code>, the parameter values won't be updated.</p>
<p>Such use can be found in <a href="https://arxiv.org/abs/2006.07733" rel="nofollow noreferrer">BYOL (Bootstrap your own latent)</a> and <a href="https://github.com/lucidrains/byol-pytorch/blob/2aa84ee18fafecaf35637da4657f92619e83876d/byol_pytorch/byol_pytorch.py#L61" rel="nofollow noreferrer">this Github webpage for BYOL pytorch implementation</a>.</p>
Is .data still useful in pytorch?
<p>I'm new to pytorch. I read much pytorch code which heavily uses tensor's <code>.data</code> member. But I search <code>.data</code> in the official document and Google, finding little. I guess <code>.data</code> contains the data in the tensor, but I don't know when we need it and when not? </p>