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

 

相关文章
|
数据处理 Python
AttributeError: module ‘numpy‘ has no attribute ‘array‘解决办法
AttributeError: module ‘numpy‘ has no attribute ‘array‘解决办法
714 0
成功解决AttributeError: module 'numpy' has no attribute 'integer'
成功解决AttributeError: module 'numpy' has no attribute 'integer'
成功解决AttributeError: module 'numpy' has no attribute 'integer'
|
TensorFlow 算法框架/工具 Python
成功解决AttributeError: module 'numpy' has no attribute 'equal'
成功解决AttributeError: module 'numpy' has no attribute 'equal'
成功解决AttributeError: module 'numpy' has no attribute 'equal'
|
2月前
|
Python
module 'numpy' has no attribute 'int'.
module 'numpy' has no attribute 'int'.
76 0
|
5月前
|
Python
AttributeError: module ‘numpy‘ has no attribute ‘int‘.
AttributeError: module ‘numpy‘ has no attribute ‘int‘.
69 0
Can‘t get attribute ‘SiLU‘ on <module ‘torch.nn.modules.activation‘
Can‘t get attribute ‘SiLU‘ on <module ‘torch.nn.modules.activation‘
AttributeError: module ‘torch.utils‘ has no attribute ‘data‘
属性错误:模块的'torch.utils'没有属性'data'
87 0
|
Python
numpy 报错:”AttributeError: module ‘numpy‘ has no attribute ‘bool‘“
numpy 报错:”AttributeError: module ‘numpy‘ has no attribute ‘bool‘“
2250 0
|
TensorFlow API 算法框架/工具
解决AttributeError: module ‘keras.utils‘ has no attribute ‘plot_model‘
解决AttributeError: module ‘keras.utils‘ has no attribute ‘plot_model‘
309 0
解决AttributeError: module ‘keras.utils‘ has no attribute ‘plot_model‘
|
TensorFlow API 算法框架/工具
解决AttributeError: module ‘tensorflow‘ has no attribute ‘div‘
解决AttributeError: module ‘tensorflow‘ has no attribute ‘div‘
164 0
解决AttributeError: module ‘tensorflow‘ has no attribute ‘div‘