吴恩达机器学习ex2,梯度参数没有更新问题

这是吴恩达第二次作业,看了很多大佬的作业,梯度都没有更新,就一直很不解
def gradient(theta, X, y):
theta = np.matrix(theta)
X = np.matrix(X)
y = np.matrix(y)

parameters = int(theta.ravel().shape[1])
grad = np.zeros(parameters)

error = sigmoid(X * theta.T) - y

for i in range(parameters):
    term = np.multiply(error, X[:,i])
    grad[i] = np.sum(term) / len(X)

return grad

第二次算最小损失函数的参数,采用库函数,调用这个库函数我知道可以不写迭代次数,和学习速度
import scipy.optimize as opt
result = opt.fmin_tnc(func=cost, x0=theta, fprime=gradient, args=(X, y))
所以调用这个函数,也可以不用更新参数么