pytorch RuntimeError(‘Boolean value of Tensor with more than one value is ambiguous‘)

(tails != -1) and (heads != neg_tails) and (heads != neg_tails) 这行报错如下:
RuntimeError(‘Boolean value of Tensor with more than one value is ambiguous’)

Boolean value of Tensor不能用and or 等操作

该为用&即可
(tails != -1) & (heads != neg_tails) & (heads != neg_tails)

这主要是and 和& 的区别

参考
https://stackoverflow.com/questions/58180153/runtimeerror-bool-value-of-tensor-with-more-than-one-value-is-ambiguous-fasta

你可能感兴趣的:(深度学习中的bug,pytorch,bug)