摘要:function [J, grad] = linearRegCostFunction(X, y, theta, lambda) %LINEARREGCOSTFUNCTION Compute cost and gradient for regularized linear %regression wi
阅读全文
摘要:用测试集来拟和参数,也不是很公平 如何选择 学习曲线
阅读全文
摘要:1 function g = sigmoidGradient(z) 2 %SIGMOIDGRADIENT returns the gradient of the sigmoid function 3 %evaluated at z 4 % g = SIGMOIDGRADIENT(z) compute
阅读全文
摘要:Theta1,2,3 和D1,2,3都是系数矩阵 thetaVec = [Theta1(:); Theta2(:);Theta3(:) ]; 里面:外面; 会把Theta1 ,Theta2,Theta3中的所有元素展开,形成一个向量thetaVec reshape 会把向量在恢复到矩阵Theta1,
阅读全文
摘要:function [J, grad] = lrCostFunction(theta, X, y, lambda) %LRCOSTFUNCTION Compute cost and gradient for logistic regression with %regularization % J =
阅读全文
摘要:100 * 100 =10000 (10000)^2/2=5*10^7 用神经网络进行运算 把-30改为-10 就成了OR 上面的陈述是错的
阅读全文
摘要:function plotData(X, y) %PLOTDATA Plots the data points X and y into a new figure % PLOTDATA(x,y) plots the data points with + for the positive exampl
阅读全文
摘要:多类别分类 过拟合问题 正则化 J(theta) = theta0 欠拟合
阅读全文
摘要:梯度计算过程如下: 线性回归: 逻辑回归 优化 使梯度下降进行逻辑回归的速度提高,适合数据比较大 >> options = optimset('GradObj','on','MaxIter','100'); >> initialTheta = zeros(2,1) initialTheta = 0
阅读全文
摘要:分类、逻辑回归 分类问题只有0和1,没有什么threshold h(x, )是[0,1]
阅读全文
摘要:function A = warmUpExercise() %WARMUPEXERCISE Example function in octave % A = WARMUPEXERCISE() is an example function that returns the 5x5 identity m
阅读全文
摘要:循环 >> v = zeros(10,1)v = 0 0 0 0 0 0 0 0 0 0 >> for i=1:10,> v(i) = 2^i;> end;>> vv = 2 4 8 16 32 64 128 256 512 1024 >> indices=1:10; >> indices indi
阅读全文
摘要:>> AA = 1 2 10 3 4 12 5 6 15 B = 2 1 3 4 2 3 6 3 3 >> A .* B % Cij = Aij*Bij,行列数目都要一致ans = 2 2 30 12 8 36 30 18 45 >> A*B%矩阵乘法ans = 70 35 39 94 47 57
阅读全文
摘要:>> A = [1 2;3 4;5 6] A = 1 2 3 4 5 6 >> A(3,2) ans = 6 >> A(2,:) %该行或列的所有元素 ans = 3 4 >> A(:,2) ans = 2 4 6 >> A([1 3], :) %取第一、三行的元素 ans = 1 2 5 6 >>
阅读全文
摘要:1&&0 %AND 1 ||0 % OR octave:6> PS1('>> '); >> octave:1> 5+6 ans = 11 octave:2> 1==2 ans = 0 octave:3> 1==2 %false %XXX %为注释 ans = 0 octave:4> 1~=2 %表示
阅读全文
摘要:标准化到相近的范围即可 这是因为θ在小范围内下降很快,在大范围内下降很慢,所以当变量非常不均匀时,θ会低效率地振荡到最优。(特征都在一个相近的范围,这样梯度下降法就能更快的收敛) 用X轴上的迭代次数绘制一个图。现在绘制成本函数,J(θ)在梯度下降迭代次数上。如果J(θ)增大,那么可能需要减小α。 总
阅读全文
摘要:即使J(,)=0,也不能是完美估计,因为其他数据可能存在误差 取任何颜色并沿着“圆”走,就可以得到相同的成本函数值,右图三个点的J(,)相同 越靠近圆心,J(,)越小 梯度下降算法可以将代价函数J()最小化 。 J(1,2)改变1,2来最小化J(1,2) 梯度下降算法不一定可以找到全局最小值 事实证
阅读全文