您的位置:首页 > 其它

机器学习基本概念-4

2016-10-10 16:53 169 查看
好久没写博客了,最近在忙一个比较棘手的问题,还好有点眉目了,所以就继续写啦,对不起看我博客的各位………..

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
,具体是:

将training sets划分为k个不重叠的部分(k trials).

使用其中的一份数据作为test sets,剩下的所有作为training sets.

计算此时的test error.

重复多次步骤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.

这次就写到这,下篇博客继续…….
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: