online-label-smoothing-pt
online-label-smoothing-pt copied to clipboard
代码报错
你好,非常感谢你提供的代码,请问一下,报错出现这个问题怎么解决呢:RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu
Hi @luckyonetwo! If you are training with gpu, then you will need to move the loss to the gpu, so it'd be something like:
from ols import OnlineLabelSmoothing
import torch
k = 4 # Number of classes
b = 32 # Batch size
criterion = OnlineLabelSmoothing(alpha=0.5, n_classes=k, smoothing=0.1).cuda()
Let me know if this didn't solve the issue and need any help