成功解决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

 

 

 

发布了1565 篇原创文章 · 获赞 6112 · 访问量 1186万+

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 代码科技 设计师: Amelia_0503

分享到微信朋友圈

×

扫一扫,手机浏览