deeplearning----学习一个简单的分类器
来源:互联网 发布:mac哪里设置环境变量 编辑:程序博客网 时间:2024/05/17 06:07
1、零一损失
我们的目的就是让错误次数(零一损失)尽可能的少:
f(x)会得出在当前的theata条件下输入对应的最大概率的输出值。换言之,我们从x预测出f(x),如果这个值就是y,那么预测成功,反之失败。
# zero_one_loss is a Theano variable representing a symbolic# expression of the zero one loss ; to get the actual value this# symbolic expression has to be compiled into a Theano function (see# the Theano tutorial for more details)zero_one_loss = T.sum(T.neq(T.argmax(p_y_given_x), y))#neq是I函数,T.neq(x,y)判断两个值是否不相等,not equal?
2、负对数自然损失
由于0-1损失是不可微的,在大型模型中去优化它相当耗费资源,因此我们最大化它的对数似然函数来完成(似然就是可能性):
也就是最小化负对数似然损失
负对数似然函数:negative log-likelihood (NLL)
# NLL is a symbolic variable ; to get the actual value of NLL, this symbolic# expression has to be compiled into a Theano function (see the Theano# tutorial for more details)NLL = -T.sum(T.log(p_y_given_x)[T.arange(y.shape[0]), y])# note on syntax: T.arange(y.shape[0]) is a vector of integers [0,1,2,...,len(y)].# Indexing a matrix M by the two vectors [0,1,...,K], [a,b,...,k] returns the# elements M[0,a], M[1,b], ..., M[K,k] as a vector. Here, we use this# syntax to retrieve the log-probability of the correct labels, y.
3、随机梯度下降SGD(Stochastic Gradient Descent)
--------------------------------------------------------------------------------
# GRADIENT DESCENT
while True:
loss = f(params)
d_loss_wrt_params = ... # compute gradient
params -= learning_rate * d_loss_wrt_params
if <stopping condition is met>:
return params
上面是一般梯度下降,基本思路是:损失--》梯度--》参数更新
随机梯度下降是一次选几个样本进行训练。最简单的方式是一次一个:
随机梯度下降SGD(Stochastic Gradient Descent)
# STOCHASTIC GRADIENT DESCENT
for (x_i,y_i) in training_set:
# imagine an infinite generator
# that may repeat examples (if there is only a finite training set)
loss = f(params, x_i, y_i)
d_loss_wrt_params = ... # compute gradient
params -= learning_rate * d_loss_wrt_params
if <stopping condition is met>:
return params
for (x_i,y_i) in training_set:
# imagine an infinite generator
# that may repeat examples (if there is only a finite training set)
loss = f(params, x_i, y_i)
d_loss_wrt_params = ... # compute gradient
params -= learning_rate * d_loss_wrt_params
if <stopping condition is met>:
return params
4、Minibatch SGD 除了一次使用多个样本,其他和sgd都一样
or (x_batch,y_batch) in train_batches:
# imagine an infinite generator
# that may repeat examples
loss = f(params, x_batch, y_batch)
d_loss_wrt_params = ... # compute gradient using theano
params -= learning_rate * d_loss_wrt_params
if <stopping condition is met>:
return params
# imagine an infinite generator
# that may repeat examples
loss = f(params, x_batch, y_batch)
d_loss_wrt_params = ... # compute gradient using theano
params -= learning_rate * d_loss_wrt_params
if <stopping condition is met>:
return params
0 0
- deeplearning----学习一个简单的分类器
- 深度学习DeepLearning.ai系列课程学习总结:6. 具有一个隐藏层的平面数据分类代码实战
- 一个机器简单的机器学习算法-KNN分类器
- deeplearning系列(五)实现一个简单的深度神经网络
- deeplearning的学习资料
- DeepLearning学习笔记-回归-分类-梯度下降
- 使用Pylearn2构建一个简单的分类器
- 贝叶斯分类器的一个简单应用(matlab)
- 使用Pylearn2构建一个简单的分类器
- 搭建一个简单的Softmax分类器(基于CS231n)
- deeplearning学习
- 快速入手一个简单的分类网络
- 做一个图片的简单分类
- matlab deeplearning用于图像分类的源代码理解
- 机器学习(二) - 一个最简单的线性分类模拟人脑神经工作
- 神经网络和深度学习(二)——一个简单的手写数字分类网络
- DeepLearning-聊一聊深度学习的weight initialization
- 简单的线性分类器
- C语言内存地址基础(ZZ)
- 转-D3D中的四元数
- node.js (感觉很好,需转载一留后用)
- [MEF]第03篇 MEF延迟加载导出部件及元数据
- 修改屏幕后立即刷新
- deeplearning----学习一个简单的分类器
- 用for语句来求总数和平均值
- 几秒前,几分钟前,几小时前,几天前,几月前,几年前的java实现
- shell设为NONE后的一些操作
- java数组的定义与使用方法
- Android开发实例之miniTwitter登录界面的实现
- SWT 托盘
- 用 Java 实现断点续传 (HTTP)
- openlayers 控件