【发布时间】:2021-04-01 15:17:33
【问题描述】:
我使用了一个使用 BERT 对评论进行分类的示例,在 link 中进行了描述。该代码是为使用 CPU 而编写的,它运行良好,但运行缓慢。在 Colab Google 中,使用多语言模型,一个 epoch 对我来说被认为是 4 小时。如果我在代码中的任何地方都用 CUDA 替换 CPU,则会出现您遇到的错误。我遵循了link 中给出的指导方针,但随后出现了另一个错误:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-3-0b35a5f74768> in <module>()
268 'labels': batch[2],
269 }
--> 270 inputs.to(device)
271 outputs = model(**inputs)
272
AttributeError: 'dict' object has no attribute 'to'
【问题讨论】: