前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >机器学习基本概念-4

机器学习基本概念-4

作者头像
GavinZhou
发布2018-01-02 16:32:14
6200
发布2018-01-02 16:32:14
举报

Hyperparameters

在ML中,我们常说的就是train,但是实际什么是train呢? 通俗点说,就是学习参数(hyperparameters) 那什么又是hyperparameters呢? 实际很简单,就是我们的model需要学习或者说需要update的参数,比如你使用了卷积(convolution),那么一定会有一个权重W和一个bias,这个就是你需要学习的参数,也就是model的hyperparameters. 需要注意的是,不同的learning algorithm学习到的参数是不一样的,也是不能通用的. 比如,你不能把别人fine-tune的一个cnn model,直接拿到你的项目上来用,除非你们的网络结构是一样的. 原因很简单,不同的model对应不同的hyperparameters.

Sets in ML

在ML中,我们常说的sets实际有三种:

  • 训练集(training sets)
  • 验证集(validation sets)
  • 测试集(test sets)

这个我们在前面的博客中已经说过了,下面我们从hyperparameters这个角度来解释一下这三种sets到底是做什么的.

首先,我们需要知道,如果光从training sets上去学习hyperparameters,其会使model的capacity最大,从而导致overfitting.

If learned on the training set, such hyperparameters would always choose the maximum possible model capacity, resulting in overfitting.

所以,我们很自然的想到了,如果有一个sets可以用来guide the selection of hyperparameters,那么是不是就可以避免了overfitting. So:

  • The subset of data used to learn the parameters is still typically called the training set.
  • The subset of data used to guide the selection of hyperparameters is called the validation set.

既然validation sets可以用来guide从training sets学习到的hyperparameters,所以一般在validation sets上的generatlization error是要小于training error.

Since the validation set is used to “train” the hyperparameters, the validation set error will underestimate the generalization error, though typically by a smaller amount than the training error.

当然,validation sets是从training set从分出来的,典型的形式是8-2分,也就是80%用来做training sets,20%用来做validation sets.

test sets毫无疑问是用来estimate the genaratlization error的,但是要注意的是:

无论如何,你定义为test sets的数据是不能参与到train和validation的过程中来的

最后总结下,在hyperparameters的角度下,三种sets的作用和定义:

  • training sets is used to learn the parameters.
  • validation sets used to estimate the generalization error during or after training, allowing for the hyperparameters to be updated accordingly.
  • After all hyperparameter optimization is complete, the generalization error may be estimated using the test set.

Cross Validation

当我们用来train的数据量很大的时候,我们通常不用担心test sets的大小问题,但是比如我们的数据量比较小,我们将其划分为training sets,validation sets and test sets之后,发现test sets的数量很小,比如只有50这个数量级,从统计学的角度来说这个存在statistical uncertainty,此时在test sets上的test error表现比较好的不一定可以真实的代表model的好坏.

此时,可以使用cross validation,具体是:

  1. 将training sets划分为k个不重叠的部分(k trials).
  2. 使用其中的一份数据作为test sets,剩下的所有作为training sets.
  3. 计算此时的test error.
  4. 重复多次步骤2,得到所有的test errors,取均值作为最终的test error.

这个方法叫做k-fold cross-validation.

The test error may then be estimated by taking the average test error across k trials. On trial i, the i-th subset of the data is used as the test set and the rest of the data is used as the training set.

这次就写到这,下篇继续…….

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2016-10-10 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Hyperparameters
  • Sets in ML
  • Cross Validation
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档