TensorFlow深度学习笔记 Logistic Classification
2016-07-10 22:49
666 查看
Logistic Classification
Github工程地址:https://github.com/ahangchen/GDLnotes欢迎star,有问题可以到Issue区讨论
官方教程地址
视频/字幕下载
About
simple but important classifierTrain your first simple model entirely end to end
下载、预处理一些图片以分类
Run an actual logistic classifier on images data
Connect bit of math and code
Detail
Linear Classifier
之所以这样建模,是因为线性公式是最简单的数学模型,仅此而已。
Input: X (e.g. the pixels in an image)
Apply a linear function to X
Giant matrix multiply
Take inputs as a big vector
Multiply input vector with a matrix, W means weights
b means biased term
Machine learning adjust weights and bias for the best prediction
Output: Y, predictions for per output class
Y is a vector, represents the probability of each label
好的预测中,正确的label的概率应当更接近1
往往得到的Y一开始不是概率,而是一些具体值(scores/logits),所以需要转换,by:
Softmax回归模型:Wikipedia
Softmax
代码soft_max.py:Softmax实现与应用
input的score差异越大(可以全部乘10试试),则输出的各项label概率差异越大,反之差异越小
Softmax只关心几个label之间的概率,不关心具体值
机器学习是一个让预测成功率升高的事情,因此是一个让score之间差异增大的过程
One hot encoding
正确预测结果应当是只有一个label成立,其他label不成立。这种情况下,预测概率最大的则是最可能的结果。
Example: take this
test
one hot encoding在label很多的情况下not work well,因为output vector到处都是0,很稀疏,因此效率低
solved by
embeddings
好处:可以measure我们与理想情况之间的距离(compare two vectors)
分类器输出:[0.7 0.2 0.1] \<=> 与label对应的真实情况:[1 0 0]
Compare two vectors: cross-entropy
D(S, L) != D(L, S)
Remember: Label don't log, for label zero
小结
找到合适的W和b,使得S和L的距离D的平均值,在整个数据集n中最小。
最小化cross-entropy
D的平均值即是Training loss,求和和矩阵相乘是个大数据的活。
两个参数的误差导致一个呈圆形的loss,所以我们要做的就是找到尽量靠近圆心的weight
机器学习问题变成了一个数值优化
解决方法之一:Gradient descent,求导
修改参数,检查误差是否变大,往变小的方向修改,直到抵达bottom。
图中weight是二维的,但事实上可能有极多的weight
原文链接:http://www.jianshu.com/p/96e12faabd91
相关文章推荐
- hdu 1863 畅通工程 (最小生成树)
- LeetCode第二天
- CSP考试 2013年12月第5题 I’m stuck! C语言实现
- Python 字典<->元组<->列表<->字符串 互转方法
- PHP Array方法归纳总结
- HDU1085(母函数)
- TensorFlow 深度学习笔记
- HDU1394 Minimum Inversion Number
- mmap内存映射
- 全国大学生信息安全竞赛writeup--暗号(reverse300)
- hdu 4899 Hero meet devil
- Java工程师成神之路
- 读取系统自带的数据库
- 读取系统自带的数据库
- 关于int main( int argc, char* argv[] ) 中arg和argv参数的解析及调试
- PHP判断是否是移动设备访问
- 毕业五年之感想--写给自己的话
- php实现的视频质量检测配置页面,异步调用不退出的进程:
- 2016第28周日
- 错误: symbol lookup error: /usr/local/lib/libreadline.so.6: undefined symbol: PC