Skip to content

  • 体验新版
    • 正在加载...
  • 登录
  • PaddlePaddle
  • Paddle
  • 合并请求
  • !22480

P
Paddle
  • 项目概览

PaddlePaddle / Paddle
大约 2 年 前同步成功

通知 2325
Star 20933
Fork 5424
  • 代码
    • 文件
    • 提交
    • 分支
    • Tags
    • 贡献者
    • 分支图
    • Diff
  • Issue 1423
    • 列表
    • 看板
    • 标记
    • 里程碑
  • 合并请求 543
  • Wiki 0
    • Wiki
  • 分析
    • 仓库
    • DevOps
  • 项目成员
  • Pages
P
Paddle
  • 项目概览
    • 项目概览
    • 详情
    • 发布
  • 仓库
    • 仓库
    • 文件
    • 提交
    • 分支
    • 标签
    • 贡献者
    • 分支图
    • 比较
  • Issue 1,423
    • Issue 1,423
    • 列表
    • 看板
    • 标记
    • 里程碑
  • 合并请求 543
    • 合并请求 543
  • Pages
  • 分析
    • 分析
    • 仓库分析
    • DevOps
  • Wiki 0
    • Wiki
  • 成员
    • 成员
  • 收起侧边栏
  • 动态
  • 分支图
  • 创建新Issue
  • 提交
  • Issue看板

refine reshape_op shape error message !22480

  • Report abuse
!22480 已合并 2月 06, 2020 由 saxon_zh@saxon_zh 创建
#<User:0x00007f7e0fbd2d58>
  • 概览 2
  • 提交 1
  • 变更 1

Created by: luotao1

reshape op增强维度类报错信息

input = np.random.random([2, 25]).astype("float32")
x = fluid.layers.data(name="x", shape=[2, 25], append_batch_size=False, dtype="float32")
shape = fluid.layers.data(name="shape", shape=[1, 4], append_batch_size=False, dtype="float32")
fluid.layers.reshape(x, shape=shape)

cpu = fluid.core.CPUPlace()
exe = fluid.Executor(cpu)

1.6版本修复PR:#20099 测试脚本:test.py.zip

1.shape参数中元素不止一个为-1时

exe.run(fluid.default_main_program(), 
           feed={"x": input, 
                      "shape": np.array([-1, -1, 5, 1]).astype("int32")})
  • 1.6修改前报错:报错内容表述不清楚,没有打印维度信息
Only one input dimension of Attr(shape) can be unknown.
  • 1.6修改后报错(如1.6版本没有修改,不需要写)
ShapeError: Only one dimension value of 'shape' in ReshapeOp can be -1. But received shape = [-1, -1, 5, 1], shape[1] is also -1.
  • 本PR修改后报错
InvalidArgumentError: Only one dimension value of 'shape' in ReshapeOp can be -1. But received shape = [-1, -1, 5, 1], shape[1] is also -1.
  [Hint: Expected unk_dim_idx == -1, but received unk_dim_idx:0 != -1:-1.] at (/home/luotao/Paddle/paddle/fluid/operators/reshape_op.cc:149)
  [operator < reshape2 > error]

2.shape参数中元素为0时,0所对应的维度出错

exe.run(fluid.default_main_program(), 
           feed={"x": input, 
                      "shape": np.array([2, 5, 5, 0]).astype("int32")})
  • 1.6 修改前报错:报错内容表述不清楚,没有打印维度信息
The index of dimension to copy from input shape must be less than the size of input shape.
  • 1.6修改后报错(如1.6版本没有修改,不需要写)
ShapeError: The index of 0 in `shape` must be less than the input tensor X's dimensions. But received shape = [2, 5, 5, 0], shape[3] = 0, X's shape = [2, 25], X's dimensions = 2.
  • 本PR修改后报错
InvalidArgumentError: The index of 0 in `shape` must be less than the input tensor X's dimensions. But received shape = [2, 5, 5, 0], shape[3] = 0, X's shape = [2, 25], X's dimensions = 2.
  [Hint: Expected static_cast<int>(i) < in_dims.size(), but received static_cast<int>(i):3 >= in_dims.size():2.] at (/home/luotao/Paddle/paddle/fluid/operators/reshape_op.cc:159)
  [operator < reshape2 > error]

3.shape参数有-1以外的负值

exe.run(fluid.default_main_program(), 
           feed={"x": input, 
                      "shape": np.array([-1, -5, 5, 1]).astype("int32")})
  • 1.6 修改前报错:
Each input dimension of Attr(shape) must not be negtive except one unknown dimension.
  • 1.6修改后报错(如1.6版本没有修改,不需要写)
ShapeError: Each dimension value of 'shape' in ReshapeOp must not be negtive except one unknown dimension. But received  shape = [-1, -5, 5, 1], shape[1] = -5.
  • 本PR修改后报错
InvalidArgumentError: Each dimension value of 'shape' in ReshapeOp must not be negtive except one unknown dimension. But received  shape = [-1, -5, 5, 1], shape[1] = -5.
  [Hint: Expected shape[i] > 0, but received shape[i]:-5 <= 0:0.] at (/home/luotao/Paddle/paddle/fluid/operators/reshape_op.cc:167)
  [operator < reshape2 > error]

4.传入无效的shape值,无法正确推断出-1对应的实际值

exe.run(fluid.default_main_program(), 
           feed={"x": input, 
                      "shape": np.array([-1, 3, 5, 1]).astype("int32")})
  • 1.6修改前报错:
Invalid shape is given.
  • 1.6修改后报错(如1.6版本没有修改,不需要写)
ShapeError: The 'shape' in ReshapeOp is invalid. The input tensor X'size must be divisible by known capacity of 'shape'. But received X's shape = [2, 25], X's size = 50, 'shape' is [-1, 3, 5, 1], known capacity of 'shape' is -15.
  • 本PR修改后报错
InvalidArgumentError: The 'shape' attribute in ReshapeOp is invalid. The input tensor X'size must be divisible by known capacity of 'shape'. But received X's shape = [2, 25], X's size = 50, 'shape' is [-1, 3, 5, 1], known capacity of 'shape' is -15.
  [Hint: Expected output_shape[unk_dim_idx] * capacity == -in_size, but received output_shape[unk_dim_idx] * capacity:-45 != -in_size:-50.] at (/home/luotao/Paddle/paddle/fluid/operators/reshape_op.cc:190)
  [operator < reshape2 > error]

5.传入无效的shape值,输入x的size与 shape不匹配

exe.run(fluid.default_main_program(), 
           feed={"x": input, 
                      "shape": np.array([1, 3, 5, 1]).astype("int32")})
  • 1.6修改前报错:
Invalid shape is given.
  • 1.6修改后报错(如1.6版本没有修改,不需要写)
ShapeError: The 'shape' in ReshapeOp is invalid. The input tensor X'size must be equal to the capacity of 'shape'. But received X's shape = [2, 25], X's size = 50, 'shape' is [1, 3, 5, 1], the capacity of 'shape' is 15.
  • 本PR修改后报错
InvalidArgumentError: The 'shape' in ReshapeOp is invalid. The input tensor X'size must be equal to the capacity of 'shape'. But received X's shape = [2, 25], X's size = 50, 'shape' is [1, 3, 5, 1], the capacity of 'shape' is 15.
  [Hint: Expected capacity == in_size, but received capacity:15 != in_size:50.] at (/home/luotao/Paddle/paddle/fluid/operators/reshape_op.cc:204)
  [operator < reshape2 > error]
指派人
分配到
审核者
Request review from
无
里程碑
无
分配里程碑
工时统计
标识: paddlepaddle/Paddle!22480
Source branch: github/fork/luotao1/reshape
渝ICP备2023009037号

京公网安备11010502055752号

网络110报警服务 Powered by GitLab CE v13.7
开源知识
Git 入门 Pro Git 电子书 在线学 Git
Markdown 基础入门 IT 技术知识开源图谱
帮助
使用手册 反馈建议 博客
《GitCode 隐私声明》 《GitCode 服务条款》 关于GitCode
Powered by GitLab CE v13.7