unsqueeze op 不支持int32类型
Created by: zenghsh3
#-*- coding: utf-8 -*-
from paddle import fluid
import numpy as np
inputs = fluid.layers.data(name='inputs',shape=[], dtype='int32')
outputs = fluid.layers.unsqueeze(inputs, axes=0)
place = fluid.CPUPlace()
exe = fluid.Executor(place=place)
exe.run(fluid.default_startup_program())
outputs_np = exe.run(feed={'inputs': np.array([1], dtype='int32')},
fetch_list=[outputs])[0]
print(outputs_np)
异常信息如下:
Traceback (most recent call last):
File "test_for_unsqueeze.py", line 7, in <module>
outputs = fluid.layers.unsqueeze(inputs, axes=0)
File "/home/zhoubo01/tools/miniconda2/envs/opensim-rl/lib/python3.6/site-packages/paddle/fluid/layers/nn.py", line 5221, in unsqueeze
"XShape": x_shape})
File "/home/zhoubo01/tools/miniconda2/envs/opensim-rl/lib/python3.6/site-packages/paddle/fluid/layer_helper.py", line 50, in append_op
return self.main_program.current_block().append_op(*args, **kwargs)
File "/home/zhoubo01/tools/miniconda2/envs/opensim-rl/lib/python3.6/site-packages/paddle/fluid/framework.py", line 1207, in append_op
op = Operator(block=self, desc=op_desc, *args, **kwargs)
File "/home/zhoubo01/tools/miniconda2/envs/opensim-rl/lib/python3.6/site-packages/paddle/fluid/framework.py", line 653, in __init__
self.desc.check_attrs()
paddle.fluid.core.EnforceNotMet: Cannot get attribute axes by type std::vector<int, std::allocator<int> >, its type is int at [/paddle/paddle/fluid/framework/attribute.h:42]