Solved by mMagmer in post #4 
              
              
                i have no proplem with following code: 
import torch
import torch.nn as nn

model = nn.Sequential(nn.Linear(28*28,10))
optimizer = torch.optim.SGD(model.parameters(), 0.03)
criterion = nn.CrossEntropyLoss()

sample_img, sample_label = torch.randn(1,28,28) , 0

sample_img.requires_grad = True
predict…