天天看點

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

更改為