empty() received an invalid combination of arguments - got (tuple, dtype=NoneType, device=NoneType),

完整报错如下:

TypeError: empty() received an invalid combination of arguments - got (tuple, dtype=NoneType, device=NoneType), but expected one of:
 * (tuple of ints size, *, tuple of names names, torch.memory_format memory_format, torch.dtype dtype, torch.layout layout, torch.device device, bool pin_memory, bool requires_grad)
 * (tuple of ints size, *, torch.memory_format memory_format, Tensor out, torch.dtype dtype, torch.layout layout, torch.device device, bool pin_memory, bool requires_grad)

参考自:https://blog.csdn.net/qq_25105061/article/details/123705011

在这里插入图片描述

说是不能是浮点型,所以这里定位到nn.Embedding的位置,feature_fields这个列表确实都是浮点型的,改成int类型即可

feature_fields = data_X.max().values + 1
feature_fields = feature_fields.astype(np.int)
print(feature_fields)
print(sum(feature_fields))
[     2      2      2      2      2      2      2      2      2      2
      2      2      2    869    525 117271  53414    210     13   9476
    407      3  18942   4274 102028   2989     26   6932  82353     10
   3192   1593      4  93248     15     14  21964     60  17029]
536887

猜你喜欢

转载自blog.csdn.net/qq_42363032/article/details/125911002
今日推荐