**解决 unsupported operand type(s) for *: ‘float‘ and ‘NoneType‘**

用juypter notebook实现机器学习算法,在训练模型报错。

theta = theta -eta * grad
if (abs(J(theta,x_b,y)-J(last_theta,x_b,y)) < epsilon):
     break

显示错误:unsupported operand type(s) for *: ‘float’ and ‘NoneType’

解决方法
1.检查运算符两边的变量是不是为同一数据类型
2. 检查函数有没有返回值,是不是忘记写return。

你可能感兴趣的:(算法,python,机器学习)