在pytorch中,想要将numpy数组x_n转化为Tensor,并指定dtype,便于训练,于是如下:
x_t=torch.Tensor(x_n,dtype=torch.float32)
若是使用GPU,则需要加上cuda:
x_t=x_t.cuda()
在pytorch中,想要将numpy数组x_n转化为Tensor,并指定dtype,便于训练,于是如下:
x_t=torch.Tensor(x_n,dtype=torch.float32)
若是使用GPU,则需要加上cuda:
x_t=x_t.cuda()