成功解决AttributeError: module 'torch.utils' has no attribute 'data'
生活随笔
收集整理的這篇文章主要介紹了
成功解决AttributeError: module 'torch.utils' has no attribute 'data'
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
成功解決AttributeError: module 'torch.utils' has no attribute 'data'
?
?
?
?
目錄
解決問題
解決思路
解決方法
?
?
?
?
解決問題
AttributeError: module 'torch.utils' has no attribute 'data'
?
?
?
?
?
解決思路
屬性錯誤:模塊的'torch.utils'沒有屬性'data'
?
?
?
?
?
解決方法
只需在頂行添加此代碼即可!
import torch.utils.data ? ? # ?新添加代碼
將
import logging import numpy as np import torchfrom . import ava_helper as ava_helper from . import cv2_transform as cv2_transform from . import transform as transform from . import utils as utilsfrom .build import DATASET_REGISTRYlogger = logging.getLogger(__name__)@DATASET_REGISTRY.register() class Ava(torch.utils.data.Dataset): """AVA Dataset"""def __init__(self, cfg, split):self.cfg = cfgself._split = split更改為
import logging import numpy as np import torch import torch.utils.data # 新添加代碼from . import ava_helper as ava_helper from . import cv2_transform as cv2_transform from . import transform as transform from . import utils as utilsfrom .build import DATASET_REGISTRYlogger = logging.getLogger(__name__)@DATASET_REGISTRY.register() class Ava(torch.utils.data.Dataset): """AVA Dataset"""def __init__(self, cfg, split):self.cfg = cfgself._split = split?
?
?
總結
以上是生活随笔為你收集整理的成功解决AttributeError: module 'torch.utils' has no attribute 'data'的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Py之portalocker:porta
- 下一篇: Py之av:av库的简介、安装、使用方法