美文网首页
pytorch lstm遇到的问题

pytorch lstm遇到的问题

作者: 追求科技的足球 | 来源:发表于2019-10-01 22:02 被阅读0次

    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)

    相关文章

      网友评论

          本文标题:pytorch lstm遇到的问题

          本文链接:https://www.haomeiwen.com/subject/qtzzyctx.html