0ad33d606682537466f3430fc6d6ac7d47460f1a,beginner_source/nlp/pytorch_tutorial.py,,,#,22

Before Change


//

x = torch.randn((2, 2))
y = torch.randn((2, 2))
z = x + y  // These are Tensor types, and backprop would not be possible

var_x = autograd.Variable(x, requires_grad=True)
var_y = autograd.Variable(y, requires_grad=True)
// var_z contains enough information to compute gradients, as we saw above
var_z = var_x + var_y
print(var_z.grad_fn)

var_z_data = var_z.data  // Get the wrapped Tensor object out of var_z...
// Re-wrap the tensor in a new variable
new_var_z = autograd.Variable(var_z_data)

After Change


// with requires_grad=True by wrapping the code block in
// ``with torch.no_grad():``
print(x.requires_grad)
print((x ** 2).requires_grad)

with torch.no_grad():
	print((x ** 2).requires_grad)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 6

Instances


Project Name: pytorch/tutorials
Commit Name: 0ad33d606682537466f3430fc6d6ac7d47460f1a
Time: 2018-04-24
Author: soumith@gmail.com
File Name: beginner_source/nlp/pytorch_tutorial.py
Class Name:
Method Name:


Project Name: deepinsight/insightface
Commit Name: ad074bd5f47d2807a62692361c5a50aa889b9d80
Time: 2018-04-22
Author: guojia@gmail.com
File Name: src/train_softmax.py
Class Name:
Method Name: get_symbol


Project Name: deepinsight/insightface
Commit Name: 5d9cfbd469ec9866c22c1d699f8eb08bdf8321fa
Time: 2018-04-22
Author: guojia@gmail.com
File Name: src/train_softmax.py
Class Name:
Method Name: get_symbol