SRN.pytorch icon indicating copy to clipboard operation
SRN.pytorch copied to clipboard

File "SRN_modules.py", line 65, in forward return x + self.pos_table[:, :x.size(1)].clone().detach() RuntimeError: The size of tensor a (320) must match the size of tensor b (256) at non-singleton dimension 1

Open wuxiaolianggit opened this issue 3 years ago • 4 comments

您好,大神,很感谢您的开源代码,非常棒,我有一个问题想问一下,n_position对应的维度是视觉特征提取后的w(宽度)吗?但是宽度是变化的,这样很容易报错了?大神我的理解对吗?

File "SRN_modules.py", line 65, in forward return x + self.pos_table[:, :x.size(1)].clone().detach() RuntimeError: The size of tensor a (320) must match the size of tensor b (256) at non-singleton dimension 1

@chenjun2hao

wuxiaolianggit avatar Oct 22 '20 00:10 wuxiaolianggit

采用的固定宽度,原文也是固定宽度------------------ 原始邮件 ------------------ 发件人: "wuxiaolianggit"<[email protected]> 发送时间: 2020年10月22日(星期四) 上午8:50 收件人: "chenjun2hao/SRN.pytorch"<[email protected]>; 抄送: "chenjun"<[email protected]>;"Mention"<[email protected]>; 主题: [chenjun2hao/SRN.pytorch] File "SRN_modules.py", line 65, in forward return x + self.pos_table[:, :x.size(1)].clone().detach() RuntimeError: The size of tensor a (320) must match the size of tensor b (256) at non-singleton dimension 1 (#14)

chenjun2hao avatar Oct 22 '20 01:10 chenjun2hao

首先很感谢大神的回复,采用固定宽度这一点我可以理解,但是特征提取后w一般会减小到原来的1/4,我看您的代码里面默认是256和26,我的理解是:图片宽度是固定256的话,n_position的维度应该默认64,我这样理解对吗? @chenjun2hao

wuxiaolianggit avatar Oct 22 '20 01:10 wuxiaolianggit

是的。------------------ 原始邮件 ------------------ 发件人: "wuxiaolianggit"<[email protected]> 发送时间: 2020年10月22日(星期四) 上午9:13 收件人: "chenjun2hao/SRN.pytorch"<[email protected]>; 抄送: "chenjun"<[email protected]>;"Mention"<[email protected]>; 主题: Re: [chenjun2hao/SRN.pytorch] File "SRN_modules.py", line 65, in forward return x + self.pos_table[:, :x.size(1)].clone().detach() RuntimeError: The size of tensor a (320) must match the size of tensor b (256) at non-singleton dimension 1 (#14)

chenjun2hao avatar Oct 22 '20 01:10 chenjun2hao

好的,非常感谢大神的回复,我也很想结合transform去做文本识别,很感谢大神的开源。

wuxiaolianggit avatar Oct 22 '20 01:10 wuxiaolianggit