【问题标题】:Byte can't be cast to the desired output type Bool字节无法转换为所需的输出类型 Bool
【发布时间】:2021-08-14 15:44:48
【问题描述】:

我试图从这个 repo https://github.com/siat-nlp/MAMS-for-ABSA 运行 bert_capsnet 模型,但我得到了这个错误

Traceback (most recent call last):
  File "train.py", line 8, in <module>
    train(config)
  File "/content/drive/MyDrive/MAMS-for-ABSA/train/train.py", line 66, in train
    logit = model(input0, input1)
  File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
  File "/content/drive/MyDrive/MAMS-for-ABSA/src/aspect_term_model/bert_capsnet.py", line 66, in forward
    sentence_mask = segment_mask & ((1 - bert_segment).byte())
RuntimeError: result type Byte can't be cast to the desired output type Bool

有人可以帮忙吗

谢谢你

【问题讨论】:

    标签: python nlp bert-language-model


    【解决方案1】:

    你可以试试:sentence_mask = segment_mask &amp; (1 - bert_segment).byte() -&gt; sentence_mask = segment_mask &amp; (1 - bert_segment).bool()。 或 -> ((1 - bert_segment).byte()) &amp; segment_mask

    前者得到 bool 类型掩码,后者得到 int8 类型掩码,如[[[1,0,0...],[1,1,0,...]],...]。在实践中,我没有发现不同。

    【讨论】:

      猜你喜欢
      • 2022-08-08
      • 2022-01-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多