unsqueeze问题
Created by: xubin1994
我使用unsqueeze的示例程序能正确扩展维度:
x = fluid.layers.data(name='x', shape=[5, 10])
y = fluid.layers.unsqueeze(input=x, axes=[1])
但是当我使用自己读取的图片数据,在动态图中转变为variable之后,却总是报错:
with fluid.dygraph.guard():
img_l = fluid.dygraph.to_variable(img_l)
img_r = fluid.dygraph.to_variable(img_r)
disp_l = fluid.dygraph.to_variable(disp_l)
disp_r = fluid.dygraph.to_variable(disp_r)
img_l = paddle.fluid.layers.stack([img_l],axis=0)
img_r = paddle.fluid.layers.stack([img_r],axis=0)
disp = paddle.fluid.layers.unsqueeze(input=disp_l, axes=[0])
···
报错信息如下:
D:\ProgramData\Anaconda3\envs\deeplearning\python.exe D:/IresNet-PaddlePaddle/stn.py
Traceback (most recent call last):
File "D:/IresNet-PaddlePaddle/stn.py", line 188, in
disp = paddle.fluid.layers.unsqueeze(input=disp_l, axes=[0])
File "D:\ProgramData\Anaconda3\envs\deeplearning\lib\site-packages\paddle\fluid\layers\nn.py", line 6941, in unsqueeze
"XShape": x_shape})
File "D:\ProgramData\Anaconda3\envs\deeplearning\lib\site-packages\paddle\fluid\layer_helper.py", line 43, in append_op
return self.main_program.current_block().append_op(*args, **kwargs)
File "D:\ProgramData\Anaconda3\envs\deeplearning\lib\site-packages\paddle\fluid\framework.py", line 1762, in append_op
kwargs.get("stop_gradient", False))
File "D:\ProgramData\Anaconda3\envs\deeplearning\lib\site-packages\paddle\fluid\dygraph\tracer.py", line 59, in trace_op
framework._current_expected_place(), stop_gradient)
paddle.fluid.core_avx.EnforceNotMet: op_kernel should not be null
only support op with kernel at [D:\1.5.1\release_cuda97\paddle\paddle\fluid\imperative\tracer.cc:217]
PaddlePaddle Call Stacks:
Windows not support stack backtrace yet.
Process finished with exit code 1 请问是什么问题呢,我的图片数据是读取正确的,并转换为numpy数组