用户12833544
RuntimeError: mat1 and mat2 shapes cannot be multiplied (32x784 and 128x10)
原创
关注作者
腾讯云
开发者社区
文档
建议反馈
控制台
登录/注册
首页
学习
活动
专区
圈层
工具
MCP广场
文章/答案/技术大牛
搜索
搜索
关闭
发布
用户12833544
社区首页
>
专栏
>
RuntimeError: mat1 and mat2 shapes cannot be multiplied (32x784 and 128x10)
RuntimeError: mat1 and mat2 shapes cannot be multiplied (32x784 and 128x10)
用户12833544
关注
发布于 2026-10-21 15:56:33
发布于 2026-10-21 15:56:33
35
0
举报
概述
摘要:PyTorch 出现矩阵乘法维度不匹配时,如何判断是输入形状还是全连接层配置出了问题?本文以 28×28 图片分类为例,演示张量展平、特征数计算和 nn.Linear 参数修正,并说明强行 reshape、临时创建网络层等常见误区。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系
cloudcommunity@tencent.com
删除。
runtime-error
python
pytorch
深度学习
问题归档
专栏文章
快讯文章归档
关键词归档
开发者手册归档
开发者手册 Section 归档