When creating a post, please add:
- Week 1
- Link to the classroom item you are referring to:
I am getting this error. Can someone help me to solve this error:
AttributeError Traceback (most recent call last)
AttributeError: 'NoneType' object has no attribute 'log'
The above exception was the direct cause of the following exception:
TypeError Traceback (most recent call last)
<ipython-input-16-03cf85aa5c36> in <module>
8
9 # Apply gradient descent
---> 10 tmp_J, tmp_theta = gradientDescent(tmp_X, tmp_Y, np.zeros((3, 1)), 1e-8, 700)
11 print(f"The cost after training is {tmp_J:.8f}.")
12 print(f"The resulting vector of weights is {[round(t, 8) for t in np.squeeze(tmp_theta)]}")
<ipython-input-15-66d818b00f54> in gradientDescent(x, y, theta, alpha, num_iters)
26 # calculate the cost function
27 #J = (-1/m)*(np.dot(y.transpose(),np.log(h)) + np.dot((1 - y).transpose(),np.log(1 - h)))
---> 28 J = -(1/m)*np.sum(y*np.log(h)+(1-y)*np.log(1-h))
29
30 # update the weights theta
TypeError: loop of ufunc does not support argument 0 of type NoneType which has no callable log method
This is the method:
{moderator edit - solution code removed}
