重置K折交叉验证中的权重

发布于 2025-01-16 22:35:45 字数 273 浏览 0 评论 0原文

在 k 重交叉验证中,为什么我们需要在每次折叠后重置权重 我们使用 thia 函数

def reset_weights(m): 如果 isinstance(m, nn.Conv2d) 或 isinstance(m, nn.Linear): m.reset_parameters() 因此,我们重置模型的权重,以便每个交叉验证折叠都从某个随机初始状态开始,而不是从之前的折叠中学习。

为什么我那么重要?我认为,如果我们不这样做,那么模型最好从所有折叠中学习并从所有折叠中更新其参数,而不是每一个都单独更新。

In k-fold cross validation why we need to reset the weights after each fold
we use thia function

def reset_weights(m):
if isinstance(m, nn.Conv2d) or isinstance(m, nn.Linear):
m.reset_parameters()
so we reset the weights of the model so that each cross-validation fold starts from some random initial state and not learning from the previous folds.

Why i that important ? and i think if we don't do that it would be better that the model learn from all folds and update its parameter from all of them not every one on its own.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

2025-01-23 22:35:45

交叉折叠验证旨在验证模型性能对于训练和测试数据的不同子样本是否一致且稳健,并以偏差较小的方式微调超参数。

如果模型具有良好的性能,在许多(通常是 5 或 10)倍的训练和测试数据中具有低方差,则意味着模型性能与数据的某些子样本无关。

https://en.wikipedia.org/wiki/Cross-validation_(统计)< /a>

验证模型后,您可以在整个数据集上训练它,而无需拆分它,以提高性能。

但仅靠这种方法无法判断模型是否过度拟合,因此请注意 CNN 正则化和验证方法。

https://www.analyticsvidhya.com/blog/2020/09/overfitting-in-cnn-show-to-treat-overfitting-in-volvingal-neural-networks/

Cross fold validation is meant to validate if the model performance is consistent and robust to different subsample of train and test data, and to fine tuning hyper parameters in a less biased way.

If the model have a good performance, with low variance among numerous (usually 5 or 10) folds of train and test data, it means that the model performance is not related to some subsample of the data.

https://en.wikipedia.org/wiki/Cross-validation_(statistics)

After validade the model, you can train it on the whole dataset, without splitting it, to improve performance.

But this approach alone can't tell if your model has overfitted or not, so take note of CNN regularization and validation methods.

https://www.analyticsvidhya.com/blog/2020/09/overfitting-in-cnn-show-to-treat-overfitting-in-convolutional-neural-networks/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文