Hi,
I am stuck at Exercise 5-Gradient descent, keep getting inf as cost, have tried many things, could someone suggest.
Regards
Hi,
I am stuck at Exercise 5-Gradient descent, keep getting inf as cost, have tried many things, could someone suggest.
Regards
@vijyant_singh so I pulled this up to look at it.
Hmmm, based on that alone it is hard exactly to know what to suggest…
Are you getting ‘inf’ on every iteration even from the beginning or it only happens later on ?
Hi Anthony,
Instead of expected output as below, i am getting Cost as INF in all ITERATIONS.
iters: 10 cost: 9.686791
iters: 20 cost: 10.297529
iters: 30 cost: 10.051127
Sorry,
Posting/sharing code is against the forum rules.
Let’s start simple here.
Please print out for me your values of the following (for the first iteration only): W1, W2, b1, b2 as well as your z and h.
Let’s see what you get and work from there.
here is my snippet of code
codes removed as posting codes is against community guidelines
@vijyant_singh sorry, one of the mods will remove your code because it is against the rules.
However, having seen it, you are doing your W1, W2, b1, b2 updates wrong-- Take a closer look at that.
*Hint: Keep in mind the purpose of the updates is to modify an existing value, not calculate a new one.
make sure you have posted your query in the right category of specialisation, course, week with mention of assignment name. as you posted in an incorrect category you are not getting response from course respective mentor response.
Also posting codes are against community guidelines, use in the pinned comment to remove the codes from your comment.
Also refrain from posting codes or asking direct solution codes from other learners. This can cause your membership at the discourse community. Refer FAQ Code of Conduct for better use of discourse community.
I am tagging @paulinpaloalto who is DLS mentor and will be right one to guide your further.
Regards
DP
Hi, Vijyant.
I don’t recognize this code as being from any of the DLS assignments. Deepti is familiar with the NLP courses and she does not recognize it either. What course is it actually from?
I thought the “update parameters” logic looked reasonable, just on general principles (meaning not knowing the full details of this assignment). Are you sure you checked the compute_cost
code? One way to get Inf
is taking log(0)
, so maybe you’ve got the labels and \hat{y} values backwards in your cost code. Or left the labels in categorical form, instead of “one hot” or something like that.
Update: sorry, when I looked at the “edit history” on your post with the source, I only saw your second version of the code. The first version was definitely wrong, as Anthony pointed out, and would have caused wrong answers for sure. Do you still get “Inf” after you tried the second version?
Apparently the function compute_cost
is just given to you, so that logic is correct. But it still matters that you call it correctly. Check the function definition and make sure you pass the arguments in the defined order. If you reverse the labels and the \hat{y} values, you’ll end up with log(0)
.