File "E:/learning/NEW/code/yolov8/NWPU/yolov8-pytorch-master/train.py", line 548, in <module> fit_one_epoch(model_train, model, ema, yolo_loss, loss_history, eval_callback, optimizer, epoch, epoch_step, epoch_step_val, gen, gen_val, UnFreeze_Epoch, Cuda, fp16, scaler, save_period, save_dir, local_rank) File "E:\learning\NEW\code\yolov8\NWPU\yolov8-pytorch-master\utils\utils_fit.py", line 34, in fit_one_epoch outputs = model_train(images) File "D:\Anaconda3\envs\pytorch\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl return forward_call(*input, **kwargs) File "D:\Anaconda3\envs\pytorch\lib\site-packages\torch\nn\parallel\data_parallel.py", line 166, in forward return self.module(*inputs[0], **kwargs[0]) File "D:\Anaconda3\envs\pytorch\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl return forward_call(*input, **kwargs) File "E:\learning\NEW\code\yolov8\NWPU\yolov8-pytorch-master\nets\yolo.py", line 165, in forward self.anchors, self.strides = (x.transpose(0, 1) for x in make_anchors(x, self.stride, 0.5)) File "E:\learning\NEW\code\yolov8\NWPU\yolov8-pytorch-master\utils\utils_bbox.py", line 25, in make_anchors sy,sx = torch.meshgrid(sy, sx, indexing='ij') if TORCH_1_10 else torch.meshgrid(sy, sx) File "D:\Anaconda3\envs\pytorch\lib\site-packages\torch\functional.py", line 463, in meshgrid return _meshgrid(*tensors, indexing=indexing) File "D:\Anaconda3\envs\pytorch\lib\site-packages\torch\functional.py", line 478, in _meshgrid return _VF.meshgrid(tensors, **kwargs,indexing='ij') # type: ignore[attr-defined] TypeError: meshgrid() got multiple values for keyword argument 'indexing'
时间: 2023-06-30 20:08:03 浏览: 238
这个错误是由于你使用了 PyTorch 的多 GPU 训练,但是在使用 meshgrid 函数时,指定了 indexing 参数两次,导致报错。你可以检查一下代码中使用 meshgrid 函数的地方,确保只指定了一次 indexing 参数。如果还有问题,可以提供更多的代码和错误信息,便于更好地定位问题。
相关问题
File "E:\learning\NEW\code\yolov8\NWPU\yolov8-pytorch-master\utils\utils_bbox.py", line 25, in make_anchors sy,sx = torch.meshgrid(sy, sx, indexing='ij') if TORCH_1_10 else torch.meshgrid(sy, sx) File "D:\Anaconda3\envs\pytorch\lib\site-packages\torch\functional.py", line 463, in meshgrid return _meshgrid(*tensors, indexing=indexing) File "D:\Anaconda3\envs\pytorch\lib\site-packages\torch\functional.py", line 478, in _meshgrid return _VF.meshgrid(tensors, **kwargs,indexing='ij') # type: ignore[attr-defined] TypeError: meshgrid() got multiple values for keyword argument 'indexing'
这个错误是因为`meshgrid`函数的`indexing`参数在PyTorch 1.10版本中被添加,而早期版本中没有该参数。你可以尝试以下两个解决方法中的任意一个:
1. 如果你使用的是PyTorch 1.10或更高版本,请删除`if TORCH_1_10 else`这一行代码,直接使用以下代码即可:
```
sy, sx = torch.meshgrid(sy, sx, indexing='ij')
```
2. 如果你使用的是早期版本的PyTorch,请将代码改为以下形式:
```
if TORCH_1_10:
sy, sx = torch.meshgrid(sy, sx, indexing='ij')
else:
sy, sx = torch.meshgrid(sy, sx)
```
用python从航海学院科研团队网页(https://hanghai.nwpu.edu.cn/kxyj/kytd.htm)抓取各科研团队的名称及其负责人的姓名,保存到1个csv文件中
首先,我们需要明确的是,由于这个网站可能会有反爬虫策略或者动态加载的内容,直接使用Python的requests和BeautifulSoup库可能无法直接获取你需要的所有信息。通常这类学术机构的详细信息可能不会直接暴露在HTML源码中,可能需要JavaScript支持的工具如Selenium或者更复杂的数据提取技术。
以下是一个基本的步骤指南,假设我们能通过简单的HTML解析获取到所需数据:
1. 导入必要的库:
```python
import requests
from bs4 import BeautifulSoup
import csv
```
2. 发送请求并获取页面内容:
```python
url = "https://hanghai.nwpu.edu.cn/kxyj/kytd.htm"
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
```
3. 查找包含团队名称和负责人信息的部分。这通常涉及到CSS选择器或者XPath路径。由于具体结构未知,这里只能给出一般示例:
```python
team_info_elements = soup.find_all('div', class_='team-item') # 假设这部分包含团队信息
```
4. 解析每个元素中的团队名称和负责人信息。这需要对实际HTML结构有了解:
```python
data = []
for element in team_info_elements:
name_element = element.find('h3') # 团队名称
if name_element:
name = name_element.text.strip()
leader_element = element.find('span', class_='leader') # 负责人姓名
if leader_element:
leader = leader_element.text.strip()
data.append((name, leader))
```
5. 将数据保存到CSV文件:
```python
with open('teams.csv', 'w', newline='', encoding='utf-8') as file:
writer = csv.writer(file)
writer.writerow(['团队名称', '负责人'])
for entry in data:
writer.writerow(entry)
```
注意:以上步骤仅供参考,实际操作时需根据网站的具体HTML结构进行调整。如果网站采用了复杂的结构或者反爬机制,上述简单的方法可能行不通,你可能需要使用更专业的网络爬虫库,如Scrapy,或者分析网站是否支持API等其他途径获取数据。
阅读全文
相关推荐
















