Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion hw1/cs285/policies/MLP_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ def update(
adv_n=None, acs_labels_na=None, qvals=None
):
# TODO: update the policy and return the loss
loss = TODO
self.optimizer.zero_grad()
predicted_actions = self(torch.Tensor(observations).to(self.device))
loss = self.loss_func(predicted_actions, torch.Tensor(actions).to(self.device))
loss.backward()
self.optimizer.step()
return {
# You can add extra logging information here, but keep this line
'Training Loss': ptu.to_numpy(loss),
Expand Down