UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at C:\cb\pytorch_1000000000000\work\aten\src\ATen\native\TensorShape.cpp:3491.) return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined]

时间: 2023-06-30 17:12:05 浏览: 87
这个警告是由于你正在使用 `torch.meshgrid` 函数时没有指定索引参数引起的。在将来的版本中,需要指定索引参数,以便在多种情况下正确地使用此函数。为了消除这个警告,你需要在调用 `torch.meshgrid` 函数时指定索引参数。具体来说,你需要将 `indexing` 参数设置为 `'ij'` 或 `'xy'`,以指定使用哪种索引方式。例如: ``` import torch x = torch.tensor([1, 2, 3]) y = torch.tensor([4, 5, 6]) # 指定使用 'ij' 索引方式 xx, yy = torch.meshgrid(x, y, indexing='ij') # 指定使用 'xy' 索引方式 xx, yy = torch.meshgrid(x, y, indexing='xy') ``` 你需要根据你的具体需求选择合适的索引方式,并在调用 `torch.meshgrid` 函数时指定索引参数,以避免这个警告。
相关问题

UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at C:\cb\pytorch_1000000000000\work\aten\src\ATen\native\TensorShape.cpp:3484.) return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined]

这个警告是由于在调用 `torch.meshgrid` 函数时没有传递 `indexing` 参数引起的。在未来的版本中,将要求必须传递 `indexing` 参数。 为了解决这个警告,你可以在调用 `torch.meshgrid` 函数时显式地传递 `indexing` 参数。`indexing` 参数接受一个字符串作为值,可以是 `"ij"` 或 `"xy"`,用于指定返回值的坐标顺序。 例如,你可以这样调用 `torch.meshgrid` 并传递 `indexing` 参数: ```python x, y = torch.meshgrid(tensors, indexing='ij') ``` 如果你不确定使用哪个值,可以查看你的代码中对 `x` 和 `y` 的后续使用,以确定正确的坐标顺序。 记住,警告并不会导致代码运行失败,但在未来的版本中可能会成为错误。为了保持代码的可移植性和稳定性,建议在调用 `torch.meshgrid` 时始终传递 `indexing` 参数。

userwarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (triggered internally at c:\cb\pytorch_1000000000000\work\aten\src\aten\native\tensorshape.cpp:2228.) return _vf.meshgrid(tensors, **kwargs) # type

### 回答1: 此警告信息提示在即将发布的更新版本中,需要传递索引参数,否则会触发警告信息。该信息是在pytorch的源代码里的tensorshape.cpp文件的2228行处触发的。操作方法为,使用_vf.meshgrid函数来操作tensors,并传递**kwargs参数(即键值对参数)。 ### 回答2: 这个warning告诉我们,在将来的pytorch版本中,调用torch.meshgrid函数时,必须要传递一个indexing参数。这个参数是用来确定生成网格的方式的。 torch.meshgrid函数是用来生成一个坐标网格的,它接受任意维度的tensor作为输入,然后输出相应维度的坐标网格。例如,如果我们有两个一维tensor x=[1,2,3]和y=[4,5,6],我们可以使用torch.meshgrid(x,y)来生成两个2维tensor X和Y,使得X[i][j]=x[i]和Y[i][j]=y[j]。这样,我们就可以在坐标系中使用(X[i][j], Y[i][j])表示一个点。 这个warning提示我们,从现在开始,使用torch.meshgrid函数时我们需要传递一个indexing参数。这个参数有两个可选值:'ij'和'xy'。如果我们传递'ij',则输出网格的第一维度代表x,第二维度代表y,这和上面的例子是一样的。如果我们传递'xy',则第一维度代表y,第二维度代表x。 在pytorch中,我们可以通过在调用torch.meshgrid函数时传递indexing参数来实现不同方式的坐标网格生成。例如,如果我们想要生成y为第一维度,x为第二维度的坐标网格,我们可以这样调用: ```python import torch x = torch.Tensor([1,2,3]) y = torch.Tensor([4,5,6]) X,Y = torch.meshgrid(x,y, indexing='xy') print(X) print(Y) ``` 输出结果为: ```python [[4., 5., 6.], [4., 5., 6.], [4., 5., 6.]] [[1., 1., 1.], [2., 2., 2.], [3., 3., 3.]] ``` 可以看到,我们得到了想要的坐标网格。因此,从现在开始,在调用torch.meshgrid函数时,一定要不忘记传递indexing参数。 ### 回答3: 这个警告信息来源于PyTorch的torch.meshgrid函数。在新的版本中,调用这个函数时需要传递一个indexing参数。这个参数指明了坐标轴的顺序。 这个函数是用来生成一个笛卡尔积场景的,比如我们有两个维度x和y,每个维度有3个值,那么我们可以使用meshgrid函数生成9个(x,y)元组组成的场景,即(0,0),(0,1),(0,2),(1,0),(1,1),(1,2),(2,0),(2,1),(2,2)。 在旧版本中,meshgrid函数默认的坐标轴的顺序是按照输入张量的顺序,比如我们输入两个张量x和y,那么生成的场景的顺序就是按照x和y的顺序。但是,在新版本中,这个默认的顺序将被替换成按照输入张量的排列顺序排列坐标轴。 这个新的特性主要是为了解决与Numpy兼容性问题。Numpy的meshgrid函数默认的坐标轴的顺序就是按照输入张量的排列顺序排列坐标轴。如果我们想在PyTorch中使用Numpy的模型或者使用PyTorch模型生成的数据在Numpy中使用,那么需要使用与Numpy一样的坐标轴顺序,这个新的特性就是为此而引入的。 在调用meshgrid函数时,建议我们也应该传递indexing参数以保证我们的代码在新的版本中可以正常运行。

相关推荐

分析错误信息D:\Anaconda3 2023.03-1\envs\pytorch\lib\site-packages\torch\functional.py:504: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at C:\actions-runner\_work\pytorch\pytorch\builder\windows\pytorch\aten\src\ATen\native\TensorShape.cpp:3484.) return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined] Model Summary: 283 layers, 7063542 parameters, 7063542 gradients, 16.5 GFLOPS Transferred 354/362 items from F:\Desktop\yolov5-5.0\weights\yolov5s.pt Scaled weight_decay = 0.0005 Optimizer groups: 62 .bias, 62 conv.weight, 59 other Traceback (most recent call last): File "F:\Desktop\yolov5-5.0\train.py", line 543, in <module> train(hyp, opt, device, tb_writer) File "F:\Desktop\yolov5-5.0\train.py", line 189, in train dataloader, dataset = create_dataloader(train_path, imgsz, batch_size, gs, opt, File "F:\Desktop\yolov5-5.0\utils\datasets.py", line 63, in create_dataloader dataset = LoadImagesAndLabels(path, imgsz, batch_size, File "F:\Desktop\yolov5-5.0\utils\datasets.py", line 385, in __init__ cache, exists = torch.load(cache_path), True # load File "D:\Anaconda3 2023.03-1\envs\pytorch\lib\site-packages\torch\serialization.py", line 815, in load return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args) File "D:\Anaconda3 2023.03-1\envs\pytorch\lib\site-packages\torch\serialization.py", line 1033, in _legacy_load magic_number = pickle_module.load(f, **pickle_load_args) _pickle.UnpicklingError: STACK_GLOBAL requires str Process finished with exit code 1

wandb: Currently logged in as: anony-mouse-584351. Use wandb login --relogin to force relogin wandb: wandb version 0.15.3 is available! To upgrade, please run: wandb: $ pip install wandb --upgrade wandb: Tracking run with wandb version 0.12.21 wandb: Run data is saved locally in /kaggle/working/yolov7/wandb/run-20230601_125414-1jenk8d0 wandb: Run wandb offline to turn off syncing. wandb: Syncing run run12 wandb: ⭐️ View project at https://wandb.ai/anony-mouse-584351/yolov7-tiny?apiKey=323c78e6a061c91ed778f8bd6fc310953f397638 wandb: 🚀 View run at https://wandb.ai/anony-mouse-584351/yolov7-tiny/runs/1jenk8d0?apiKey=323c78e6a061c91ed778f8bd6fc310953f397638 wandb: WARNING Do NOT share these links with anyone. They can be used to claim your runs. /opt/conda/lib/python3.7/site-packages/torch/functional.py:568: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at /usr/local/src/pytorch/aten/src/ATen/native/TensorShape.cpp:2227.) return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined] WARNING: Dataset not found, nonexistent paths: ['/kaggle/working/yolov7/noduleyolov1iyolov7pytorch/valid/images'] Traceback (most recent call last): File "yolov7/train.py", line 616, in <module> train(hyp, opt, device, tb_writer) File "yolov7/train.py", line 97, in train check_dataset(data_dict) # check File "/kaggle/working/yolov7/yolov7/utils/general.py", line 173, in check_dataset raise Exception('Dataset not found.') Exception: Dataset not found. wandb: Waiting for W&B process to finish... (failed 1). Press Control-C to abort syncing. wandb: wandb: Synced run12: https://wandb.ai/anony-mouse-584351/yolov7-tiny/runs/1jenk8d0?apiKey=323c78e6a061c91ed778f8bd6fc310953f397638 wandb: Synced 5 W&B file(s), 0 media file(s), 0 artifact file(s) and 0 other file(s) wandb: Find logs at: ./wandb/run-20230601_125414-1jenk8d0/logs

最新推荐

recommend-type

HP-Socket编译-Linux

HP-Socket编译-Linux
recommend-type

JavaScript_生活在Discord上的开源社区列表.zip

JavaScript
recommend-type

JavaScript_MultiOn API.zip

JavaScript
recommend-type

JavaScript_简单和完整的React DOM测试工具,鼓励良好的测试实践.zip

JavaScript
recommend-type

JavaScript_成为一个Nodejs开发者.zip

JavaScript
recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

实现实时数据湖架构:Kafka与Hive集成

![实现实时数据湖架构:Kafka与Hive集成](https://img-blog.csdnimg.cn/img_convert/10eb2e6972b3b6086286fc64c0b3ee41.jpeg) # 1. 实时数据湖架构概述** 实时数据湖是一种现代数据管理架构,它允许企业以低延迟的方式收集、存储和处理大量数据。与传统数据仓库不同,实时数据湖不依赖于预先定义的模式,而是采用灵活的架构,可以处理各种数据类型和格式。这种架构为企业提供了以下优势: - **实时洞察:**实时数据湖允许企业访问最新的数据,从而做出更明智的决策。 - **数据民主化:**实时数据湖使各种利益相关者都可
recommend-type

可见光定位LED及其供电硬件具体型号,广角镜头和探测器,实验设计具体流程步骤,

1. 可见光定位LED型号:一般可使用5mm或3mm的普通白色LED,也可以选择专门用于定位的LED,例如OSRAM公司的SFH 4715AS或Vishay公司的VLMU3500-385-120。 2. 供电硬件型号:可以使用常见的直流电源供电,也可以选择专门的LED驱动器,例如Meanwell公司的ELG-75-C或ELG-150-C系列。 3. 广角镜头和探测器型号:一般可采用广角透镜和CMOS摄像头或光电二极管探测器,例如Omron公司的B5W-LA或Murata公司的IRS-B210ST01。 4. 实验设计流程步骤: 1)确定实验目的和研究对象,例如车辆或机器人的定位和导航。
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。