I tried the following, all of them are fine
W=torch.empty(3, requires_grad=False)
W=torch.zeros(3, requires_grad=False)
W=torch.ones(3, requires_grad=False)
W=torch.randn(3, requires_grad=False); W[0]=0.1; W[1]=0.1;W[2]=0.1
W_numpy=numpy.array([0.1,0.1,0.1],dtype=‘float32’); W=torch.from_numpy(W_numpy)
W=torch.arange(0,3)
W=torch.linspace(0,1,3)
W=torch.logspace(-10, 10,3)
W=torch.full((3,), 3.141592)
W=torch.tensor([0.1, 0.1, 0.1])
If I use the option “requires_grad=True” with any of the above expressions, then I got
“RuntimeError: leaf variable has been moved into the graph interior”
Then I run:
W=torch.tensor([0.1, 0.1, 0.1])
W.requires_grad
Out[17]: False
W.is_leaf
Out[18]: True
W[0]=w1 * w2;  W[1]=w2 * w3;  W[2]=w3 * w1
W.is_leaf
Out[19]: False
W=torch.tensor([0.1, 0.1, 0.1], requires_grad=True)
W.requires_grad
Out[20]: True
W.is_leaf
Out[21]: True
W[0]=w1 * w2;  W[1]=w2 * w3;  W[2]=w3 * w1
W.is_leaf
Out[22]: False
So, what the error message really means?