Machine Learning Week4 ex4.m
来源:互联网 发布:芳纶纸淘宝 编辑:程序博客网 时间:2024/09/21 10:46
这次作业中的文件都相对来说比较有意思。按照ex4的顺序来进行研究,那么可以看到,首先是displayData,也就是对于数据进行显示。
之后是对于参数的读取。
根据参数来计算损失,此时并不添加regularization。
下一步就是包含regularizatio的J。
simgoidGradient就是sigmoid函数的导函数。
初始化参数的选取是随机的,但是还有一个debug版本的初始化参数的选取,是定值。
checkNNGradients应该就是对于梯度的计算是否正确的判断了,第一次是lambda=0,第二次是lambda=3,不同的正则化参数下,结果是不一样的。
训练神经网络,使用的是fmincg.m函数。
训练好之后,可视化参数,可以看出,相对来说较为复杂的区域都在中间部分的。
最后是对于数据集合的预测。
computeNumericalGradient.m
这个函数是对于theta的数值的计算。就是更改一个小epislon,然后计算梯度。
function numgrad = computeNumericalGradient(J, theta)%COMPUTENUMERICALGRADIENT Computes the gradient using "finite differences"%and gives us a numerical estimate of the gradient.% numgrad = COMPUTENUMERICALGRADIENT(J, theta) computes the numerical% gradient of the function J around theta. Calling y = J(theta) should% return the function value at theta.% Notes: The following code implements numerical gradient checking, and % returns the numerical gradient.It sets numgrad(i) to (a numerical % approximation of) the partial derivative of J with respect to the % i-th input argument, evaluated at theta. (i.e., numgrad(i) should % be the (approximately) the partial derivative of J with respect % to theta(i).)% numgrad = zeros(size(theta));perturb = zeros(size(theta));e = 1e-4;for p = 1:numel(theta) % Set perturbation vector perturb(p) = e; loss1 = J(theta - perturb); loss2 = J(theta + perturb); % Compute Numerical Gradient numgrad(p) = (loss2 - loss1) / (2*e); perturb(p) = 0;endend
0 0
- Machine Learning Week4 ex4.m
- Machine Learning Week4 lrCostFunction.m
- Machine Learning Week4 predictOneVsAll.m
- Machine Learning Week4 oneVsAll.m
- Machine Learning Week4 ex3_nn.m
- Coursera Machine Learning Ex4
- machine-learning-ex4
- Machine Learning(Andrew)Week4
- Machine Learning week4
- Machine Learning--Andrew Ng--week4
- 斯坦福Machine Learning Week4总结(包括作业)
- Coursera Machine Learning Week4 学习笔记
- 【Coursera Machine Learning】 Week4 学习笔记
- [笔记]Coursera Machine Learning Week4,5
- coursera Stanford Machine Learning Week5 Ex4机器学习 实验4
- Machine Learning displayData.m
- Machine Learning Week8 computeCentroids.m
- Machine Learning Week8 findClosestCentroids.m
- JDBC-实例1
- tjut 4681
- Basic Math
- UPnP中Control Point的基本流程
- iOS9开始的新特性
- Machine Learning Week4 ex4.m
- phpstudy的安装0
- 动态规划思想总结
- abaqus umat介电弹性体Mooney-Rivlin model + electrostatic
- C#控制台 将一维string数组转换成二维char类型输出并输出
- 河南多校大一训练赛 (田忌赛马)
- 前端开发结构图
- Qt Quick文档翻译
- 工作周报7.25-7.30