fminunc在numpy中交替 [英] fminunc alternate in numpy

查看:95
本文介绍了fminunc在numpy中交替的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Python中的fminunc函数(从octave/matlab)是否有替代方法?我有一个用于二进制分类器的成本函数.现在,我想运行梯度下降以获取最小的θ值. octave/matlab实现将如下所示.

Is there an alternative to the fminunc function (from octave/matlab) in python? I have a cost function for a binary classifier. Now I want to run gradient descent to get minimum value of theta. The octave/matlab implementation will look like this.

%  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或任何其他梯度下降算法实现.

I have converted my costFunction in python using numpy library, and looking for the fminunc or any other gradient descent algorithm implementation in numpy.

推荐答案

此处提供了有关所需功能的更多信息:http://docs.scipy.org/doc/scipy-0.10.0/reference/tutorial/optimize.html

There is more information about the functions of interest here: http://docs.scipy.org/doc/scipy-0.10.0/reference/tutorial/optimize.html

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

Also, it looks like you are doing the Coursera Machine Learning course, but in Python. You might check out http://aimotion.blogspot.com/2011/11/machine-learning-with-python-logistic.html; this guy's doing the same thing.

这篇关于fminunc在numpy中交替的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆