gpt4 book ai didi

python - fminunc 在 numpy 中交替

转载 作者:IT老高 更新时间:2023-10-28 20:43:29 24 4
gpt4 key购买 nike

python 中的 fminunc 函数(来自 octave/matlab)是否有替代方法?我有一个二元分类器的成本函数。现在我想运行梯度下降来获得 theta 的最小值。 octave/matlab 实现将如下所示。

%  Set options for fminunc
options = optimset('GradObj', 'on', 'MaxIter', 400);

% Run fminunc to obtain the optimal theta
% This function will return theta and the cost
[theta, cost] = ...
fminunc(@(t)(costFunction(t, X, y)), initial_theta, options);

我已经使用 numpy 库在 python 中转换了我的 costFunction,并在 numpy 中寻找 fminunc 或任何其他梯度下降算法实现。

最佳答案

这里有更多关于感兴趣的函数的信息:http://docs.scipy.org/doc/scipy-0.10.0/reference/tutorial/optimize.html

此外,您似乎正在学习 Coursera 机器学习类(class),但使用的是 Python。您可以查看 http://aimotion.blogspot.com/2011/11/machine-learning-with-python-logistic.html ;这家伙也在做同样的事情。

关于python - fminunc 在 numpy 中交替,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18801002/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com