PaddlePaddle / Paddle

PArallel Distributed Deep LEarning: Machine Learning Framework from Industrial Practice (『飞桨』核心框架,深度学习&机器学习高性能单机、分布式训练和跨平台部署)
http://www.paddlepaddle.org/
Apache License 2.0
22.11k stars 5.55k forks source link

【论文复现赛】加载预训练模型,动转静态图报错。 #42628

Closed CPones closed 2 years ago

CPones commented 2 years ago

bug描述 Describe the Bug

AIStudio复现地址:https://aistudio.baidu.com/aistudio/projectdetail/3856073 版本:提issue,bug记录。 位置:模型推理

TypeError: In transformed code:

File "/home/aistudio/CaiT/cait.py", line 493, in forward
x = self.forward_features(x)
File "/home/aistudio/CaiT/cait.py", line 481, in forward_features
# Self-Attention blocks
File "/home/aistudio/CaiT/cait.py", line 373, in forward
x = self.attn(x)
File "/home/aistudio/CaiT/cait.py", line 228, in forward
    B, H, C = x.shape # H: num_patches
    qkv = self.qkv(x).chunk(3, axis=-1)
    q, k, v = map(self.transpose_multihead, qkv) #[B, num_heads, num_patches, single_head_dim]
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE

    q = q * self.scale

File "/home/aistudio/CaiT/cait.py", line 220, in transpose_multihead
new_shape = x.shape[:-1] + [self.num_heads, self.dim_head]

TypeError: can only concatenate tuple (not "list") to tuple

其他补充信息 Additional Supplementary Information

No response

paddle-bot-old[bot] commented 2 years ago

您好,我们已经收到了您的问题,会安排技术人员尽快解答您的问题,请耐心等待。请您再次检查是否提供了清晰的问题描述、复现代码、环境&版本、报错信息等。同时,您也可以通过查看官网API文档常见问题历史IssueAI社区来寻求解答。祝您生活愉快~

Hi! We've received your issue and please be patient to get responded. We will arrange technicians to answer your questions as soon as possible. Please make sure that you have posted enough message to demo your request. You may also check out the APIFAQGithub Issue and AI community to get the answer.Have a nice day!

minghaoBD commented 2 years ago

@CPones 可以把 [self.num_heads, self.dim_head] 的数据类型改为tuple: (self.num_heads, self.dim_head)

这是一个demo: image