【问题标题】:How can I solve linear inverse problem Ax=b using Deep Neural Network? [closed]如何使用深度神经网络解决线性逆问题 Ax=b? [关闭]
【发布时间】:2019-08-31 06:35:11
【问题描述】:

我正在尝试使用深度神经网络解决线性逆问题Ax=b。但我对机器学习完全陌生,所有教程都是关于分类的。那么,谁能提供一些关于如何使用深度神经网络解决Ax=b问题的教程链接(代码、视频、论文)?

【问题讨论】:

    标签: python machine-learning optimization deep-learning inversion


    【解决方案1】:

    来自blog的示例

    import torch
    dim = 2
    A = torch.rand(dim, dim, requires_grad=False)
    b = torch.rand(dim, 1,  requires_grad=False)
    x = torch.autograd.Variable(torch.rand(dim, 1), requires_grad=True)
    stop_loss = 1e-2
    step_size = stop_loss / 3.0
    print('Loss before: %s' % (torch.norm(torch.matmul(A, x) - b)))
    for i in range(1000*1000):
        Δ = torch.matmul(A, x) - b
        L = torch.norm(Δ, p=2)
        L.backward()
        x.data -= step_size * x.grad.data # step
        x.grad.data.zero_()
        if i % 10000 == 0: print('Loss is %s at iteration %i' % (L, i))
        if abs(L) < stop_loss:
            print('It took %s iterations to achieve %s loss.' % (i, step_size))
            break
    print('Loss after: %s' % (torch.norm(torch.matmul(A, x) - b)))
    

    【讨论】:

    猜你喜欢
    • 2020-08-09
    • 2018-01-23
    • 2017-09-07
    • 2023-03-10
    • 2016-09-13
    • 2012-06-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多