首页 > 其他分享 >pytorch loss.backward()核心理解

pytorch loss.backward()核心理解

时间:2022-12-13 00:12:14浏览次数:40  
标签:loss pytorch ones c2 c1 backward grad

    X = torch.ones(2, 2, requires_grad=False)
    w = torch.ones(2, 2, requires_grad=True)
    c1 = X*w
    c1.backward()
    print(w.grad)

    # 会报错
    c2 = c1 * X
    c2.backward()

#重新建立c1的链子
c1=X*w
    c2 = c1 * X
    c2.backward()

 

 

 

标签:loss,pytorch,ones,c2,c1,backward,grad
From: https://www.cnblogs.com/chentianyu/p/16977505.html

相关文章