zl程序教程

您现在的位置是:首页 >  其它

当前栏目

Providing a bool or integral fill_value without setting the optional dtype or out arguments...

The or ... value out Without arguments setting
2023-09-14 09:13:19 时间

1.报错

报错信息如下:

Providing a bool or integral fill_value without setting the optional dtype or out arguments is currently unsupported. In PyTorch 1.7, when dtype and out are not set a bool fill_value will return a tensor of torch.bool dtype, and an integral fill_value will return a tensor of torch.long dtype.

可以参考pytorch 的官方文档进行查看

原因

版本问题,导致错误。

修改案例

这里提供我个人的修改案例,供大家参考:
在这里插入图片描述非常简单,只需要提供tensor返回的数据类型就可以了,而不用再在后面加.torch.long()这种方式了