Course 5 week 1 dinosaur clip function

Hi I think I am updating the clip function correctly. However, I am getting the below error.
I am looping over gradient in [dWax, dWaa, dWya, db, dby] and using np.clip function and storing out=gradient. Not sure why the function is not seeing all the five inputs. Any help will be greatly appreciated.

Thanks,
Kiran Sanubala

Below is the error I am getting.

Gradients for mValue=10

ValueError Traceback (most recent call last)
in
29 print("\033[92mAll tests passed!\x1b[0m")
30
—> 31 clip_test(clip, 10)
32 clip_test(clip, 5)
33

in clip_test(target, mValue)
10 gradients = {“dWax”: dWax, “dWaa”: dWaa, “dWya”: dWya, “db”: db, “dby”: dby}
11
—> 12 gradients2 = target(gradients, mValue)
13 print(“gradients[“dWaa”][1][2] =”, gradients2[“dWaa”][1][2])
14 print(“gradients[“dWax”][3][1] =”, gradients2[“dWax”][3][1])

in clip(gradients, maxValue)
15 gradients = copy.deepcopy(gradients)
16
—> 17 dWaa, dWax, dWya, db, dby = gradients[‘dWaa’], gradients[‘dWax’], gradients[‘dWya’], gradients[‘db’],
18 gradients[‘dby’]
19

ValueError: not enough values to unpack (expected 5, got 4)

I found the issue and fixed it. I had a tab in the gradients assignment and the last valued ‘dby’ went to the next line.

Great! Yes, that was what I was going to guess. That code was given to you as part of the template, so there was no need to modify it.

1 Like