Deep Learning by Andrew Ng --- Softmax regression
来源:互联网 发布:纳米材料就业知乎 编辑:程序博客网 时间:2024/05/17 21:44
这是UFLDL的编程练习。
Weight decay(Softmax 回归有一个不寻常的特点:它有一个“冗余”的参数集)后的cost function和梯度函数:
- cost function:
J(θ)=−1m⎡⎣∑i=1m∑j=1k1{y(i)=j}logeθTjx(i)∑kl=1eθTlx(i)⎤⎦+λ2∑i=1k∑j=0nθ2ij - 梯度函数:
bsxfun函数的使用:
- to prevent overflow, simply subtract some large constant value from each of theterms before computing the exponential:
θTjx(i)
% M is the matrix as described in the text
M = bsxfun(@minus, M, max(M, [], 1)); - use the following code to compute the hypothesis:
% M is the matrix as described in the text
M = bsxfun(@rdivide, M, sum(M)
练习题答案(建议自己完成,后参考):
- softmaxCost.m:
M = theta*data; %exp(theta(l)' * x(i))M = bsxfun(@minus, M, max(M, [], 1)); h = exp(M);h = bsxfun(@rdivide, h, sum(h)); size(groundTruth);cost = -1/numCases*sum(sum(groundTruth.*log(h)))+lambda/2*sum(sum(theta.^2)); thetagrad = -1/numCases*((groundTruth-h)*data')+lambda*theta;
- softPredict.m:
[index , pred]= max(theta * data,[],1);
0 0
- Deep Learning by Andrew Ng --- Softmax regression
- Deep Learning by Andrew Ng --- Sparse Autoencoder
- Deep Learning by Andrew Ng --- self-taught
- Deep Learning by Andrew Ng --- stacked autoencoder
- Deep learning by Andrew Ng --- Linear Decoder
- Deep Learning by Andrew Ng --- Sparse coding
- Deep learning------------softmax regression
- Machine Learning by Andrew Ng --- Logistic Regression by using Regularization
- Machine Learning by Andrew Ng ---Linear Regression with one variable
- Machine Learning by Andrew Ng---Linear Regression with multiple variables
- Machine Learning by Andrew Ng --- Logistic Regression with two classes
- Deep Learning by Andrew Ng --- PCA and whitening
- Deep learning:十三(Softmax Regression)
- 【Deep Learning】3、Softmax Regression
- Deep learning:十三(Softmax Regression)
- Deep learning:十三(Softmax Regression)
- Deep learning:十三(Softmax Regression)
- Andrew Ng Deep Learning Tutorial中Softmax分类器梯度求导过程
- 黑马程序员_OC内存管理
- 蓝桥杯 古代赌局
- Windows DLL文件的加载过程[简述]
- 算法导论-递归插入
- opengl中深度冲突问题以及几种可能的解决方案
- Deep Learning by Andrew Ng --- Softmax regression
- 2014网页菜单新趋势——侧边栏菜单设计案例展示
- 贪心算法--看电视
- C语言常见的内存分配
- String to Integer(atoi)
- tcp状态参数设置
- android LayoutInflater.inflate()的参数及其用法
- OpenGL中使用Shader的基本步骤
- 如何让自己configure找到需要的库?