C2_W4_Assignment_#UNQ_C5 GRADED FUNCTION

Good day to all!
I’m having a problem executing #UNQ_C5 GRADED FUNCTION: gradient_descent.

Unfortunately, I can’t figure out what is causing the error:

TypeError Traceback (most recent call last)
in
7 num_iters = 150
8 print(“Call gradient_descent”)
----> 9 W1, W2, b1, b2 = gradient_descent(data, word2Ind, N, V, num_iters)

in gradient_descent(data, word2Ind, N, V, num_iters, alpha, random_seed, initialize_model, get_batches, forward_prop, softmax, compute_cost, back_prop)
48
49 # get gradients
—> 50 grad_W1, grad_W2, grad_b1, grad_b2 = back_prop(x, y, yhat, h, W2, b1, b2, batch_size)
51
52 # update weights and biases

TypeError: back_prop() missing 1 required positional argument: ‘batch_size’

The function specified in the error is implemented correctly, in my opinion:

get gradients

    grad_W1, grad_W2, grad_b1, grad_b2 = back_prop(x, y, yhat, h, W2, b1, b2, batch_size)

Please tell me what is my mistake?

Hi @Mikhail2 ,

This error shows that the function back_prop is being called without the required number of arguments. Verify that the back_prop function is defined to take the parameters you are passing (def back_prop(x, y, yhat, h, W2, b1, b2, batch_size):...). Also, make sure that batch_size is defined and has the expected value before this call.

Hope this helps!

Hi, Alireza_Saei!
All tests for calculating back_prop in a separate task (previous task) were completed with the correct result.

image

Hey there, you didn’t pass W1 as a function argument! Make sure to include that in the code provided in the first post when calling the function!

1 Like

Hi, Alireza_Saei!
Thank you for your support. The code was worked, but I have different results, not as “Expected results”

And, I understand that my results may differ from those specified in the task, but then, in the testing block, I get an error and the number of tests passed is 8/16

Do you have the latest notebook? You can update it by pushing the end dates(only if the deadline has passed). Otherwise, wrong implementation is causing the error!

If you need further help you can send your code via a private message to me to check for issues!

Hi @Mikhail2

I have checked both of your C1 and C5 codes, both seems to be fine. your issue could be arising from other code cells. So kindly DM C2, C3 and C4 codes via personal DM

Regards
DP