用$ W_P^P $的子级别学习

发布于 2025-02-13 23:49:06 字数 432 浏览 1 评论 0 原文

我正在尝试实施论文“与Wasserstein损失一起学习”(链接为)然后,更具体地说,我尝试在第4页上实现算法1在纸上。 但是,我不知道如何通过Optimizer.Step(),例如SGD来反映我的模型算法1的结果。

例如,当我们用Pytorch计算损失时,我们可以使用以下代码进行学习。

optimizer.zero_grad()
loss.backward()
optimizer.step()

然而,算法1输出了沃斯堡损失的梯度随熵分析的梯度。因此,我们不能像对损失的损失更新不同。

如何通过算法1更新我的模型?

I am trying to implement the paper 'Learning with Wasserstein loss' (the link is https://arxiv.org/abs/1506.05439) then, more specifically, I try to implement the algorithm 1 at page 4 in the paper.
However, I don't know how to reflect the result of algorithm 1 to my model via optimizer.step(), e.g. SGD.

For example, when we calculate loss with pytorch, then we can progress the learning with such a following code.

optimizer.zero_grad()
loss.backward()
optimizer.step()

However, the algorithm 1 output the gradient of wasserstein loss with entropic reguralization. Therefore we cant't update it unlike the case of caliculating a loss.

How to update my model by algorithm 1?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文