Pytorch报警告UserWarning: To copy construct from a tensor
详细的警告如下: 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(sourceTen
·
详细的警告如下:
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).
feature = torch.tensor( , dtype=torch.float32)
其实就是在将某个变量转成tensor过程中指定变量类型警告!
如果在转为tensor时需要改变变量类型需要用下面的语句
torch.as_tensor(torch.from_numpy(feature), dtype=torch.float32)
参考文献
更多推荐
已为社区贡献19条内容
所有评论(0)