Thanks Naruto for your input. Are you saying that, if we are building network in the following fashion, we don’t need to worry about the setting the any tensor to have require_grad = True?
I am very confused because I was reading the tutorial from here: autograd tutorial 53, and it was emphasizing about the require_grad= True, where as in the example below, we don’t care about this.
So in short, my question is, we only use require_grad=True when we are building network from scratch (like the pytorch tutorial link). If we are building network in the fashion given by below’s code, we don’t need to worry about this?
class Policy(nn.Module):
    def __init__(self):
        super(Policy, self).__init__()
        self.affine1 = nn.Linear(4, 128)
        self.affine2 = nn.Linear(128, 2)

        self.saved_log_probs = []
        self.rewards = []

    def forward(self, x):
        x = F.relu(self.affine1(x))
        action_scores = self.affine2(x)
        return F.softmax(action_scores, dim=1)


policy = Policy()
optimizer = optim.Adam(policy.parameters(), lr=1e-2)
eps = np.finfo(np.float32).eps.item()