torch.einsum 不接受浮点张量?

torch.einsum doesn't accept float tensors?

我收到以下错误:

RuntimeError: Expected object of scalar type Long but got scalar type Float for argument #3 'mat2' in call to _th_addmm_out

我使用torch.einsum如下:

mu = torch.einsum('ijl, akij -> akl', idxs, activation_map)

我不明白这一点,因为在文档中他们也在使用浮点张量 (https://pytorch.org/docs/stable/generated/torch.einsum.html)。选择长张量也不是办法,因为 activation_map 中的所有值都在 0 和 1 之间。

您的第一个参数 idxs 似乎是 Long.
类型 torch.einsum 的所有输入张量应为 Float.