check_feed_shape_type
Created by: ellinyang
- 标题:mask_rcnn模型预测时报错
- 版本、环境信息: 1)PaddlePaddle版本:paddle1.7.1 2)GPU:nvidia V100, cuda7/cudnn9.0 4)系统环境:Linux 14
- 复现信息:
训练时不固定输入大小,但因业务需要,在导出模型时需固定了输入op的大小为(3, 800, 1344),故如下代码修改了模型,导致预测时报错。但同样是固定输入大小,faster/cascade rcnn可以顺利infer,但mask_rcnn/retinanet不能,请问是什么原因呢?
prog.global_block().var(op.name).desc.set_shape(tensor_shape) # # 动态infer,修改所有shape block_desc = prog.global_block().desc for prog_op in prog.global_block().ops: prog_op.desc.infer_shape(block_desc)
- 错误日志:
Traceback (most recent call last):
File "infer_demo.py", line 230, in <module>
infer(args)
File "infer_demo.py", line 163, in infer
return_numpy=False)
File "/root/miniconda3/lib/python3.7/site-packages/paddle/fluid/executor.py", line 783, in run
six.reraise(*sys.exc_info())
File "/root/miniconda3/lib/python3.7/site-packages/six.py", line 703, in reraise
raise value
File "/root/miniconda3/lib/python3.7/site-packages/paddle/fluid/executor.py", line 778, in run
use_program_cache=use_program_cache)
File "/root/miniconda3/lib/python3.7/site-packages/paddle/fluid/executor.py", line 831, in _run_impl
use_program_cache=use_program_cache)
File "/root/miniconda3/lib/python3.7/site-packages/paddle/fluid/executor.py", line 902, in _run_program
self._feed_data(program, feed, feed_var_name, scope)
File "/root/miniconda3/lib/python3.7/site-packages/paddle/fluid/executor.py", line 580, in _feed_data
check_feed_shape_type(var, cur_feed)
File "/root/miniconda3/lib/python3.7/site-packages/paddle/fluid/executor.py", line 230, in check_feed_shape_type
(var.name, len(var.shape), var.shape, feed_shape))
ValueError: The fed Variable 'image' should have dimensions = 4, shape = (-1, 3, 800, 1344), but received fed shape [1, 3, 1088, 800] on each device