警告解决方案:To copy construct from a tensor, it is recommended to use...

代码

x_train, y_train, x_valid, y_valid = map(
    torch.tensor, (x_train, y_train, x_valid, y_valid)
)

在这里插入图片描述

警告:

D:\Users\ThinkStation\anaconda3\envs\pytorch\lib\site-packages\ipykernel_launcher.py:2: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).

解决方法:
torch.tensor改成torch.as_tensor

x_train, y_train, x_valid, y_valid = map(
    torch.as_tensor, (x_train, y_train, x_valid, y_valid)
)

你可能感兴趣的:(问题解决方案集锦,pip,python,开发语言)