import numpy as np
import torch
import torch.nn
datas = np.array([[1, 2], [3, 4]])
labels = np.array([[2, 3], [4, 5]])
loss_fn = torch.nn.MSELoss()
input = torch.autograd.Variable(torch.from_numpy(datas).float(), requires_grad=True)
target = torch.autograd.Variable(torch.from_numpy(labels).float(), requires_grad=True)
print(input)
print(target)
loss = loss_fn(input, target)
print(loss)
torch.autograd.variable()实例用法
猜你喜欢
转载自blog.csdn.net/weixin_40823740/article/details/115319975
今日推荐
周排行