固定随机种子是否有必要?

为什么要固定随机种子

固定随机性能解决这些问题:实验结果可复现、有效的对比实验

为什么需要随机性?

In applied machine learning, we run a machine learning “algorithm” on a dataset to get a machine learning “model.” The model can then be evaluated on data not used during training or used to make predictions on new data, also not seen during training.

  • Algorithm: Procedure run on data that results in a model (e.g. training or learning).
  • Model: Data structure and coefficients used to make predictions on data.

这里的Algorithm具有随机性。They allow the model to escape local optima or deceptive local optima where the learning algorithm might get such, and help find better solutions, even a global optima. Neural networks (deep learning) are a stochastic machine learning algorithm. The random initial weights allow the model to try learning from a different starting point in the search space each algorithm run and allow the learning algorithm to “break symmetry” during learning. The random shuffle of examples during training ensures that each gradient estimate and weight update is slightly different.

What should we do

在我们做对比试验,需要验证不同trick、不同模型、不同超参数的有效性的时候,最好是能固定随机种子使得模型是可复现的。但使用nondeterministic的算法往往能取得更好的performance,带来更快的运算速度。

另外,随机种子不是一个超参数,并不存在一个最好的随机种子。

如果是为了工程中的模型部署,更好地做法是去跑多个模型(指多次训练得到的input到output的映射function),计算其统计特征(比如std、mean),用来评估模型好坏。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值