首页 Paddle框架 帖子详情
transpose操作dimension问题
收藏
快速回复
Paddle框架 问答深度学习 2538 4
transpose操作dimension问题
收藏
快速回复
Paddle框架 问答深度学习 2538 4
  • 版本、环境信息:
    1)PaddlePaddle版本:1.6.2
    2)python:3.6.3

  • 训练信息
    1)单机单卡

  • 问题描述

image_input = fluid.layers.data(name="image",
                                  shape=[512,
                                         512,
                                         self.image_channels],
                                  dtype="float32")
image_feature = fluid.layers.transpose(image_input, perm=[0, 3, 1, 2])
image_feature = fluid.layers.conv2d(image_feature, num_filters=16, filter_size=3, act="leaky_relu")

打印image的shape为(-1, 512, 512, 1)
但在transpose操作中报错,说 tensor's dimension is 3, axis's size is 4,tensor的dimension不应该是4吗

1578452769              The place is:CUDAPlace(0)
Tensor[image]
        shape: [512,512,1,]
        dtype: f
        data: 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
/opt/conda/envs/table_parsing/lib/python3.7/site-packages/paddle/fluid/executor.py:779: UserWarning: The following exception is not an EOF exception.
  "The following exception is not an EOF exception.")
Traceback (most recent call last):
  File "models/train.py", line 180, in <module>
    train()
  File "models/train.py", line 159, in train
    results = train_one_batch(feed_data)
  File "models/train.py", line 103, in train_one_batch
    fetch_list=fetch_vars)
  File "/opt/conda/envs/table_parsing/lib/python3.7/site-packages/paddle/fluid/executor.py", line 780, in run
    six.reraise(*sys.exc_info())
  File "/opt/conda/envs/table_parsing/lib/python3.7/site-packages/six.py", line 696, in reraise
    raise value
  File "/opt/conda/envs/table_parsing/lib/python3.7/site-packages/paddle/fluid/executor.py", line 775, in run
    use_program_cache=use_program_cache)
  File "/opt/conda/envs/table_parsing/lib/python3.7/site-packages/paddle/fluid/executor.py", line 822, in _run_impl
    use_program_cache=use_program_cache)
  File "/opt/conda/envs/table_parsing/lib/python3.7/site-packages/paddle/fluid/executor.py", line 899, in _run_program
    fetch_var_name)
paddle.fluid.core_avx.EnforceNotMet:

--------------------------------------------
C++ Call Stacks (More useful to developers):
--------------------------------------------
0   std::string paddle::platform::GetTraceBackString<std::string const&>(std::string const&, char const*, int)
1   paddle::platform::EnforceNotMet::EnforceNotMet(std::string const&, char const*, int)
2   paddle::operators::TransposeOp::InferShape(paddle::framework::InferShapeContext*) const
3   paddle::operators::Transpose2Op::InferShape(paddle::framework::InferShapeContext*) const
4   paddle::framework::OperatorWithKernel::RunImpl(paddle::framework::Scope const&, paddle::platform::Place const&, paddle::framework::RuntimeContext*) const
5   paddle::framework::OperatorWithKernel::RunImpl(paddle::framework::Scope const&, paddle::platform::Place const&) const
6   paddle::framework::OperatorBase::Run(paddle::framework::Scope const&, paddle::platform::Place const&)
7   paddle::framework::Executor::RunPreparedContext(paddle::framework::ExecutorPrepareContext*, paddle::framework::Scope*, bool, bool, bool)
8   paddle::framework::Executor::Run(paddle::framework::ProgramDesc const&, paddle::framework::Scope*, int, bool, bool, std::vector<std::string, std::allocator<std::string> > const&, bool)

------------------------------------------
Python Call Stacks (More useful to users):
------------------------------------------
  File "/opt/conda/envs/table_parsing/lib/python3.7/site-packages/paddle/fluid/framework.py", line 2488, in append_op
    attrs=kwargs.get("attrs", None))
  File "/opt/conda/envs/table_parsing/lib/python3.7/site-packages/paddle/fluid/layer_helper.py", line 43, in append_op
    return self.main_program.current_block().append_op(*args, **kwargs)
  File "/opt/conda/envs/table_parsing/lib/python3.7/site-packages/paddle/fluid/layers/nn.py", line 8100, in transpose
    attrs={'axis': perm})
  File "/root/paddle/GNN-Table-Parsing/models/image_conv_block.py", line 18, in build_image_conv_block
    image_feature = fluid.layers.transpose(image_input, perm=[0, 3, 1, 2])
  File "/root/paddle/GNN-Table-Parsing/models/gnn_model.py", line 117, in build_node_features
    image_features = image_conv_block.build_image_conv_block(image)
  File "/root/paddle/GNN-Table-Parsing/models/gnn_model.py", line 282, in build_model
    node_features = self.build_node_features(image, vertex_text, vertex_features)
  File "/root/paddle/GNN-Table-Parsing/models/gnn_model.py", line 310, in train_net
    edge_output_list = self.build_model()
  File "models/train.py", line 58, in train
    accuracies, inference_program = gnn_model.train_net()
  File "models/train.py", line 180, in <module>
    train()

----------------------
Error Message Summary:
----------------------
Error: ShapeError: The input tensor's dimension should be equal to the axis's size. But received input tensor's dimension is 3, axis's size is 4
  [Hint: Expected x_rank == axis_size, but received x_rank:3 != axis_size:4.] at (/paddle/paddle/fluid/operators/transpose_op.cc:46)
  [operator < transpose2 > error]
0
收藏
回复
全部评论(4)
时间顺序
wanghaoshuang
#2 回复于2020-01

建议这样试一下:

image_input = fluid.data(name="image",
                                  shape=[None, 512,
                                         512,
                                         self.image_channels],
                                  dtype="float32")
0
回复
AIStudio792052
#3 回复于2020-01

试了下 还是会报相同的错误

0
回复
wanghaoshuang
#4 回复于2020-01

feed data的代码也贴一下?

0
回复
wanghaoshuang
#5 回复于2020-01

已确认feed数据时少了一维。

0
回复
需求/bug反馈?一键提issue告诉我们
发现bug?如果您知道修复办法,欢迎提pr直接参与建设飞桨~
在@后输入用户全名并按空格结束,可艾特全站任一用户