【MindSpore】ValueError: For reshape the shape of inputs_x is [256, 48, 64] the value of input_shape v

MindSpore报错截图如下:
ValueError: For reshape the shape of inputs_x is [256, 48, 64] the value of input_shape value is [48,64] the profuct of the shape of input_x should be equal to product of input_shape, but product of the shape of input_x is 786432, product of input shape is 3072
在这里插入图片描述
首先我们要学会看框架提供给我们的报错调用栈,通过调用栈我们可以知道是由于哪里的Reshape算子导致的,从图中我们可以知道报错Reshape算子的位置位于
mindspore/ops/_grad/grad_math_ops.py文件的86行,

然后,通过vim去定位我们可以知道此处其实是Mul算子的反向报错意思是输入input_x的shape和我们的目标shape大小不一致,输入input_x的shape是一个[256,48,64],而这里的目标shape是[48,64]。

解决方法
我们知道了是Mul算子报错,其实通过调用栈能够大致知道哪个Mul算子里面的反向报错。Mul算子有两个输入x和y,在这里我们可以将x 的shape扩一维,然后再tile成和y一样的shape。总之一句话,正向x和y的shape一致就可以。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值