Calcuting Y_targets in DQL in Reinforcement learning practice lab

So, I am trying to calculate y_targets for DQL for the Reinforcement Learning practice lab but struggling how to calculate it and getting the following error.

How I am calculating it: Based on hints in the exercise, I am checking if 1 - done_vals is true and if yes, I am setting y_targets equal to rewards + gamma * max_qsa otherwise I am setting y_targets equal to rewards. What am I doing wrong? Do I need a For loop here?

You are doing the exact opposite of what’s required by the exercise, please read the description carefully

Thanks for the response! I tried flipping the order of assignment but still get different assertion error.

In the previous one I got loss = 0.72891 and now loss = 0.154475

1 Like

Hello, please follow these steps:

  1. insert this line right before return loss in your function.
print(rewards, gamma, max_qsa, done_vals, y_targets, q_values, loss)
  1. On the menu bar, click “Kernel” > “restart”

  2. run code cells one by one, and stop after running the cell for test_compute_loss(compute_loss)

  3. given the printed raw numbers, check with the formula in the description for whether your function’s computed loss is as expected

  4. if you can’t figure out the problem, please share the printing result and any error here again.

Raymond

Thank you very much for your reply! Very sorry for the delay in my response! I printed but again getting the same error,
Results below



I wonder if how I am assigning value is in correct. I am using a simple assignment statement. Do I need to use any tensor flow specific assignment here?

Hello @Anupam_Kulkarni,

I suggest you to verify your work with

if ... :
    .....
    print('done = ', done, 'first set of statements ran')
else:
    ....
    print('done = ', done, 'second set of statements ran')

Raymond

PS: We can’t share assignment code here so I removed it.