1、RuntimeError: Expected tensor for argument #1 'indices' to have scalar type Long; but got CPUType instead (while checking arguments for embedding)
这个是因为input的参数为float类型,要改成int,可以使用astype(int)
2、RuntimeError: Expected object of backend CUDA but got backend CPU for argument #3 'index'
是因为数据在cpu上然而要在gpu上跑,需要数据后加.cuda()
3、RuntimeError: Trying to backward through the graph a second time, but the buffers have already been freed. Specify retain_graph=True when calling backward the first time.
释放了缓冲区,backward改为loss.backward(retain_graph=True)
网友评论