Can‘t get attribute ‘_rebuild_tensor_v2‘ on module ‘torch._utils‘

Posted 努力奋斗-不断进化

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Can‘t get attribute ‘_rebuild_tensor_v2‘ on module ‘torch._utils‘相关的知识,希望对你有一定的参考价值。

最简单的解决办法

 

在出问题的程序中,插入

 

import torch._utils
try:
    torch._utils._rebuild_tensor_v2
except AttributeError:
    def _rebuild_tensor_v2(storage, storage_offset, size, stride, requires_grad, backward_hooks):
        tensor = torch._utils._rebuild_tensor(storage, storage_offset, size, stride)
        tensor.requires_grad = requires_grad
        tensor._backward_hooks = backward_hooks
        return tensor
    torch._utils._rebuild_tensor_v2 = _rebuild_tensor_v2

 

相关问题

 

Question about ‘_rebuild_tensor_v2’
 

以上是关于Can‘t get attribute ‘_rebuild_tensor_v2‘ on module ‘torch._utils‘的主要内容,如果未能解决你的问题,请参考以下文章

PythonAttributeError: Can‘t get attribute ‘Vocab‘ on <module ‘gensim.models.word2vec‘ from

PythonAttributeError: Can‘t get attribute ‘Vocab‘ on <module ‘gensim.models.word2vec‘ from

PythonAttributeError: Can‘t get attribute ‘Vocab‘ on <module ‘gensim.models.word2vec‘ from

PythonAttributeError: Can‘t get attribute ‘Vocab‘ on <module ‘gensim.models.word2vec‘ from

Unpickling 保存的 pytorch 模型会引发 AttributeError: Can't get attribute 'Net' on <module '__main__' 尽管内联

yolov5 5.0 报错日常Can‘t get attribute ‘SPPF‘ on <module ‘models.common‘ from ‘D:\Pycharm\Code\yolov5