We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
首先感谢你的贡献,正因为你开源的资料让我在学习吴恩达的机器学习编程作业时有了充分的参考。但是在我运行的过程中,发现一些小问题,可能是因为python版本不同,所以导致我的代码报错,现将问题指出,以方便后来的学习者。 在2.logistic regression中的第41和42行涉及到log函数,运行会报错:
RuntimeWarning: divide by zero encountered in log xxxxxxxx
这是因为当某些数据log涉及到无穷的时候,原始的np.log中内存的计算单位内存就会益出,导致后续无法计算,所以我们为期新增一个有固定值的小数位。保证其计算的时候浮点数维持在1e-5,运行不会报错。因此该两行代码改为
first = np.multiply(-y, np.log(sigmoid(X * theta.T) + 1e-5)) second = np.multiply((1-y), np.log(1 - sigmoid(X * theta.T) + 1e-5))
我的python版本为python 3.9,希望对出现同样问题的同学有参考价值。
The text was updated successfully, but these errors were encountered:
No branches or pull requests
首先感谢你的贡献,正因为你开源的资料让我在学习吴恩达的机器学习编程作业时有了充分的参考。但是在我运行的过程中,发现一些小问题,可能是因为python版本不同,所以导致我的代码报错,现将问题指出,以方便后来的学习者。
在2.logistic regression中的第41和42行涉及到log函数,运行会报错:
这是因为当某些数据log涉及到无穷的时候,原始的np.log中内存的计算单位内存就会益出,导致后续无法计算,所以我们为期新增一个有固定值的小数位。保证其计算的时候浮点数维持在1e-5,运行不会报错。因此该两行代码改为
我的python版本为python 3.9,希望对出现同样问题的同学有参考价值。
The text was updated successfully, but these errors were encountered: