In the “optimization” Exercise the test does not pass.
It shows an error with “costs” - one element NaN.
The thing is, I’m not doing anything with “cost” here - and the part where I had to input a cost function just worked fine. Any ideas?
Inside the Optimize() function, there is a call to propagate() which returns cost as one of the return parameters, and within the propagate(), the cost is calculated. Looking at the AssertionError, the calculation for cost is fine. It is likely there is a problem when appending the cost returned from propagate() to the array costs
Use a print statement to print out what is stored in the array costs, that should help to locate where the problem might be.
Notice that the first value in the costs array (the one for iteration 0) is correct, but the second one for iteration 100 is wrong (the cost is NaN in that case). So one thing to look carefully at would be your logic for updating the parameters.
thx, Kic & paulinpaloalto - you pointed me in the right direction.
It made a mistake in my code with the w/b updating, in a way that I added the gradient (times learning factor) instead of substracting it. That does not matter at the start (-> therefore the first cost value for iteration 0 was correct) but then things can spin out of control → cost result after 100 interations NaN.
Cheers, Hamster