I have a problem with course 1 week 3 practice lab, exercise 2. My output does not match the expected output. Can anyone help, please?
Thanks!
I have a problem with course 1 week 3 practice lab, exercise 2. My output does not match the expected output. Can anyone help, please?
Thanks!
Hello @Ayse_Nehir_Cevik Welcome to the community!
In your problem, Firstly you should have to complete the code of compute_cost function perfectly. Like summation of cost for all training example and divide by training sample (m).
Here use the equations to complete the compute_cost function:
𝑙𝑜𝑠𝑠(𝑓𝐰,𝑏(𝐱(𝑖)),𝑦(𝑖)) = (−𝑦(𝑖)log(𝑓𝐰,𝑏(𝐱(𝑖)))−(1−𝑦(𝑖))log(1−𝑓𝐰,𝑏(𝐱(𝑖)))
𝑓𝐰,𝑏(𝐱(𝑖)) = 𝑔(𝐰⋅𝐱(𝐢)+𝑏), where g is the sigmoid function
Pseudocode:
Initialize loss equal to zero
for ith training example to total training example:
𝑓𝐰,𝑏(𝐱(𝑖)) = 𝑔(𝐰⋅𝐱(𝐢)+𝑏) [for multiply use numpy.dot() function]
𝑙𝑜𝑠𝑠(𝑓𝐰,𝑏(𝐱(𝑖)),𝑦(𝑖)) += (−𝑦(𝑖)log(𝑓𝐰,𝑏(𝐱(𝑖)))−(1−𝑦(𝑖))log(1−𝑓𝐰,𝑏(𝐱(𝑖)))
return cost/m