【发布时间】:2020-08-24 09:02:42
【问题描述】:
我正在研究优化运输,我必须解决这个问题:
在哪里
的模拟位置。
我可以将转移计划和函数 u 近似为 并尝试用神经网络找到 theta 和 w。
使用 Arrow_Huwicz 算法我有以下简单的程序:我们在 [1,N] 中绘制一些 k 并在 w 和 中迭代地最小化这个函数,这样在第 n 步, 和 直到达到itermax
def Arrow_Hurwicz_algorithm(dim,NMC,S12,itermax):
w = torch.autograd.Variable(torch.rand(dim, 1), requires_grad=True)
theta = torch.autograd.Variable(torch.rand(dim, 1), requires_grad=True)
step_size = 1e-6
for i in range(itermax):
k = randrange(NMC)
L = JN(S12,k,theta,w)
L.backward()
theta.data -= step_size * theta.grad.data # step
F = JN(S12,k,theta,w)
F.backward()
w.data += step_size * w.grad.data
w.grad.data.zero_()
theta.grad.data.zero_()
optw = w.detach().numpy()[0][0]
optth = theta.detach().numpy()[0][0]
return JN2(S12,optth,optw)
我如何在 pytorch 中使用 Adam 随机梯度执行相同的操作?
【问题讨论】:
-
能否请您使用online-latex 输入您的方程式,问题中的方程式很难阅读。
-
我需要至少 10 个声望 XD,我想我可以在 quant exchange 上发布链接
标签: machine-learning pytorch gradient