MatLab实现Softmax Regression
来源:互联网 发布:停用移动数据总是弹出 编辑:程序博客网 时间:2024/06/07 03:37
资料参考于NG的深度学习网站:http://ufldl.stanford.edu/tutorial/supervised/SoftmaxRegression/,实现课程中的练习题目
Softmax Regression
Softmax原理
softmax是Logistic Regression的泛化,其属于广义线性回归模型,具体的证明推导可以参见该博客;
由上面的证明可以得到损失函数:
梯度为:
其中:
Softmax实现
维度
因为实现过程中使用的都是向量运算,所以首先注明在实现过程中的各变量的维度。
(n指的是加上常数项+1后的特征个数)
(k指减去最后一项-1后的分类个数)
1.
2.
3.
4.
5.
6.
实现过程
1.首先求
b=theta'*X; b(size(b,1)+1,:)=0; a=exp(b); sum_col = sum(a); P=bsxfun(@rdivide,a,sum_col);
2.构造一个矩阵A(
A = zeros(num_classes,m); I = sub2ind(size(A),y,1:size(A,2));%search for the position A(I) = 1;
3.计算
P_log=log(P); f=-sum(P_log(I));%I表示位置
4.计算梯度
g = - X*(A(1:size(A,1)-1,:)-P(1:size(A,1)-1,:))'; g=g[:]
5.最后使用minfunc函数求解
——2017.2.11
0 0
- MatLab实现Softmax Regression
- 使用Tensorflow实现Softmax Regression
- tensorflow 实现一个Softmax Regression
- softmax regression的tensorflow实现
- SoftMax regression
- Softmax Regression
- softmax regression
- Softmax Regression
- Softmax Regression
- Softmax regression
- Softmax Regression
- [03]tensorflow实现softmax回归(softmax regression)
- TensorFlow实现Softmax Regression识别手写数字
- Tensorflow实现Softmax Regression 手写识别MNIST
- TensorFlow实现Softmax Regression手写数字识别
- TensorFlow 实现 Softmax Regression 识别手写数字
- TensorFlow 实现Softmax Regression 识别数字
- TensorFlow实现Softmax Regression识别手写数字
- 使用Jackson的@JsonFormat注解时出现少八个小时
- [TPYBoard-Micropython之会python就能做硬件 2] 利用micropython控制NOKIA 5110屏
- CSU-ACM2017寒假集训1B-简单二分和三分 HDU - 2141
- 5-6 列出连通集(25分)
- 聊聊高并发系统之HTTP缓存
- MatLab实现Softmax Regression
- 使用Callable和Future两个类,来获得线程执行后的结果
- 应用多级缓存模式支撑海量读服务
- 团体程序设计天梯赛-练习集-L2-014. 列车调度(LIS)
- atoi()
- 聊聊java高并发系统之异步非阻塞
- java工具类快速定位
- 洛谷 1094——纪念品分组(贪心)
- openssl 的加密速度测试