成功解决AttributeError: module 'torch.utils' has no attribute 'data'

成功解决AttributeError: module 'torch.utils' has no attribute 'data'

目录

解决问题

解决方法


解决问题

AttributeError: module 'torch.utils' has no attribute 'data'

解决方法

只需在顶行添加此代码即可!
import torch.utils.data     #  新添加代码

import logging
import numpy as np
import torch

from . import ava_helper as ava_helper
from . import cv2_transform as cv2_transform
from . import transform as transform
from . import utils as utils

from .build import DATASET_REGISTRY

logger = logging.getLogger(__name__)


@DATASET_REGISTRY.register()
class Ava(torch.utils.data.Dataset):  
    """
    AVA Dataset
    """

    def __init__(self, cfg, split):
        self.cfg = cfg
        self._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 utils

from .build import DATASET_REGISTRY

logger = logging.getLogger(__name__)


@DATASET_REGISTRY.register()
class Ava(torch.utils.data.Dataset):  
    """
    AVA Dataset
    """

    def __init__(self, cfg, split):
        self.cfg = cfg
        self._split = split
发布了1560 篇原创文章 · 获赞 6061 · 访问量 1156万+

猜你喜欢

转载自blog.csdn.net/qq_41185868/article/details/103882523
今日推荐