成功解决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     #  新添加代码

1. import logging
2. import numpy as np
3. import torch
4. 
5. from . import ava_helper as ava_helper
6. from . import cv2_transform as cv2_transform
7. from . import transform as transform
8. from . import utils as utils
9. 
10. from .build import DATASET_REGISTRY
11. 
12. logger = logging.getLogger(__name__)
13. 
14. 
15. @DATASET_REGISTRY.register()
16. class Ava(torch.utils.data.Dataset):  
17. """
18.     AVA Dataset
19.     """
20. 
21. def __init__(self, cfg, split):
22.         self.cfg = cfg
23.         self._split = split

更改为

1. import logging
2. import numpy as np
3. import torch
4. import torch.utils.data     #  新添加代码
5. 
6. from . import ava_helper as ava_helper
7. from . import cv2_transform as cv2_transform
8. from . import transform as transform
9. from . import utils as utils
10. 
11. from .build import DATASET_REGISTRY
12. 
13. logger = logging.getLogger(__name__)
14. 
15. 
16. @DATASET_REGISTRY.register()
17. class Ava(torch.utils.data.Dataset):  
18. """
19.     AVA Dataset
20.     """
21. 
22. def __init__(self, cfg, split):
23.         self.cfg = cfg
24.         self._split = split


相关文章
|
10月前
|
数据处理 Python
AttributeError: module ‘numpy‘ has no attribute ‘array‘解决办法
AttributeError: module ‘numpy‘ has no attribute ‘array‘解决办法
575 0
|
TensorFlow 算法框架/工具 Python
成功解决AttributeError: module 'numpy' has no attribute 'equal'
成功解决AttributeError: module 'numpy' has no attribute 'equal'
成功解决AttributeError: module 'numpy' has no attribute 'equal'
成功解决AttributeError: module 'numpy' has no attribute 'integer'
成功解决AttributeError: module 'numpy' has no attribute 'integer'
成功解决AttributeError: module 'numpy' has no attribute 'integer'
|
2月前
|
Python
AttributeError: module ‘numpy‘ has no attribute ‘int‘.
AttributeError: module ‘numpy‘ has no attribute ‘int‘.
25 0
|
11月前
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'
76 0
|
Python
numpy 报错:”AttributeError: module ‘numpy‘ has no attribute ‘bool‘“
numpy 报错:”AttributeError: module ‘numpy‘ has no attribute ‘bool‘“
2195 0
|
TensorFlow API 算法框架/工具
解决AttributeError: module ‘keras.utils‘ has no attribute ‘plot_model‘
解决AttributeError: module ‘keras.utils‘ has no attribute ‘plot_model‘
279 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‘
150 0
解决AttributeError: module ‘tensorflow‘ has no attribute ‘div‘
|
PyTorch 算法框架/工具
问题解决:AttributeError: 'module' object has no attribute '_rebuild_tensor_v2'
问题解决:AttributeError: 'module' object has no attribute '_rebuild_tensor_v2'
252 0