Input, output and indices must be on the current device解决办法

报错
Input, output and indices must be on the current device

检查模型需要的输入是否放在gpu上

ids = batch['input_ids'].to(device)
types = batch['token_type_ids'].to(device)
mask = batch['attention_mask'].to(device)
labels = batch['labels'].to(device)

还有非常重要的一点

模型也要放到GPU上

model.to(device)

你可能感兴趣的:(python,深度学习)