当前位置: 代码迷 >> 综合 >> pytorch RuntimeError(‘Boolean value of Tensor with more than one value is ambiguous‘)
  详细解决方案

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

热度:24   发布时间:2023-12-18 06:56:02.0

(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

  相关解决方案