What should I do if the output of my model can’t be the input of the loss function?
I’m trying to implement a policy gradient method in RL and the output of my model need some more calculations before computing the loss. What should I do with my output and the loss function in such case?
pointW
Maybe posting some code of the calculations you want do might be helpful to understand what you want to do?
AjayTalati
Here is part of my codes: <SCODE>    self.steps_done = 0
    self.matches_done = 0
    self.win_count = 0

def forward(self, x):
    x = F.relu(self.conv1(x))
    x = F.relu(self.conv2(x))
    x = F.relu(self.conv3(x))
    x = F.relu(self.conv4(x))
    x = F.relu(self.conv5(x))
    x = F.relu(self.conv6(x))
    x = F.relu(self.conv7(x))
    x = x.view(x.size(0), -1)
    x = F.softmax(x)
    return x
<ECODE> <SCODE>output = model(Variable(epstate.type(dtype)))

discounted_epr = discount_rewards(epreward)
discounted_epr -= torch.mean(discounted_epr)
discounted_epr /= torch.std(discounted_epr)

discounted_epr.resize_(discounted_epr.size()[0], 1)
discounted_epr = discounted_epr.expand(discounted_epr.size()[0], 81)

epy = Variable(epy, requires_grad=False)
discounted_epr = Variable(discounted_epr, requires_grad=False)

loss = (epy - output).mul(discounted_epr).pow(2).mean()

optimizer.zero_grad()
loss.backward()
optimizer.step()<ECODE>
pointW
pointW
AjayTalati