当前位置:网站首页>Pytorch_ Geometric (pyg) uses dataloader to report an error runtimeerror: sizes of tenants must match except in dimension 0
Pytorch_ Geometric (pyg) uses dataloader to report an error runtimeerror: sizes of tenants must match except in dimension 0
2022-06-25 09:41:00 【Deno_ V】
Use Pytorch_Geometric(PyG) Time to build DataLoader, from DataLoader Take samples Batch Times wrong :RuntimeError: Sizes of tensors must match except in dimension 0.
The error is caused by data alignment error ,1 individual batch Is a collection of multiple samples , An error occurred when the samples were spliced into a set , The law is as follows :
- Use pytorch-geometric Of dataloader when ,batch Merge rules for each sample of
- attribute edge_index Special rules , Each sample edge_index by 2 × e i 2\times e_i 2×ei, Then merge n Samples form a batch After that batch.edge_index The size is 2 × ( ∑ i = 1 n e i ) 2\times(\sum_{i=1}^n e_i) 2×(∑i=1nei)
- If all other attributes are tensor, Expand according to the first dimension , For example, for attributes x x x, The first sample size is d 1 × d 2 d_1\times d_2 d1×d2, The second sample size is d 3 × d 2 d_3\times d_2 d3×d2, If there is one batch These two samples are included ,batch.x The size of will be ( d 3 + d 1 ) × d 2 (d_3+d_1)\times d_2 (d3+d1)×d2. Here is a huge pit , It requires that in addition to the first dimension , All other dimensions must be the same size !! Otherwise, an error will be reported
RuntimeError: Sizes of tensors must match except in dimension 0. - Other properties if not tensor, It will return normally according to the list ,batch.x=[ sample 1 Of x, sample 2 Of x, sample 3 Of x]
How to solve :
- If using torch tensor Caused by the , Think of ways to align other than the first dimension , Width of other dimensions .
- If there is no way to align , Use non tensor Data type substitution , For example, a list of .
- The last choice , Appoint batch_size=1 To avoid .
dataloader=DataLoader(MyData,batch_size=1)
边栏推荐
- 股票在线开户安全吗?找谁可以办理?
- Armbian version name comparison
- 在指南针上面开户好不好,安不安全?
- Japanese online notes for postgraduate entrance examination (9): composition template
- vscode试图过程写入管道不存在
- Arduino bootloader burning summary
- Voiceprint Technology (III): voiceprint recognition technology
- [zufe school competition] difficulty classification and competition suggestions of common competitions in the school (taking Zhejiang University of Finance and economics as an example)
- 2022 postgraduate entrance examination experience post -- Alibaba Business School of Hangzhou Normal University -- management science and Engineering (including the recommendation of books and course
- 2022 meisai question a idea sharing
猜你喜欢

Vscode attempted to write the procedure to a pipeline that does not exist

Wechat official account can reply messages normally, but it still prompts that the service provided by the official account has failed. Please try again later

Creo makes a mobius belt in the simplest way

Applet cloud development joint table data query and application in cloud function

C语言刷题随记 —— 猴子吃桃

Mapping mode of cache

Format analysis and explanation of wav file
![[competition - Rural Revitalization] experience sharing of Zhejiang Rural Revitalization creative competition](/img/b4/84c30ed112c4dffd8d51697b2f4a4f.jpg)
[competition - Rural Revitalization] experience sharing of Zhejiang Rural Revitalization creative competition

Prediction of pumpkin price based on BP neural network

How to "transform" small and micro businesses (II)?
随机推荐
Voiceprint Technology (II): Fundamentals of audio signal processing
CSV parameterization in JMeter
What are the PMP scores?
Question B of the East China Cup: how to establish a population immune barrier against novel coronavirus?
pmp考试题型需要注意哪些?
Use Navicat to compare data differences and structure differences of multi environment databases, and automatic DML and DDL scripts
[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate
Benefits and types of cloud network technology
Is it safe to open an account in a mobile phone or a securities company?
manhattan_slam环境配置
手机办理长城证券开户靠谱安全吗?
Reza RA series - development environment construction
Atguigu---17-life cycle
How to "transform" small and micro businesses (I)?
Cassava tree disease recognition based on vgg16 image classification
[IOU] intersection over union
请问在手机上开户股票,还是去证券公司开户安全?
[matlab] image binarization (imbinarize function)
[MySQL learning notes 21] storage engine
Notes on writing questions in C language -- monkeys eat peaches