gpt4 book ai didi

deep-learning - 如何对pytorch中的变量应用指数移动平均衰减?

转载 作者:行者123 更新时间:2023-12-04 06:05:24 25 4
gpt4 key购买 nike

我正在阅读以下论文。它对变量使用 EMA 衰减。
Bidirectional Attention Flow for Machine Comprehension

During training, the moving averages of all weights of the model are maintained with the exponential decay rate of 0.999.



他们使用TensorFlow,我找到了EMA的相关代码。
https://github.com/allenai/bi-att-flow/blob/master/basic/model.py#L229

在 PyTorch 中,如何将 EMA 应用于变量?

最佳答案

移动平均是梯度下降中动量的关键概念。

PyTorch document你可以找到:
optimizer = torch.optim.SGD(model.parameters(), lr=0.1, momentum=0.9)
更改参数 momentum到你想要的值。

关于deep-learning - 如何对pytorch中的变量应用指数移动平均衰减?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47679355/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com