Created by: qili93
For Paddle version > 1.6, the following command will fail with error
x2paddle_fc1_bias = fluid.layers.create_parameter(dtype='float32', shape=[128], name='x2paddle_fc1_bias', attr='x2paddle_fc1_bias', default_initializer=Constant(0.0))
with error log as following:
Traceback (most recent call last):
File "../../x2paddle/core/op_mapper.py", line 123, in save_inference_model
inputs, outputs = model.x2paddle_net()
File "/workspace/Github-qili93/X2Paddle/model_dir/mnist/model_with_code/model.py", line 7, in x2paddle_net
x2paddle_fc1_bias = fluid.layers.create_parameter(dtype='float32', shape=[128], name='x2paddle_fc1_bias', attr='x2paddle_fc1_bias', default_initializer=Constant(0.0))
File "/workspace/anaconda3/envs/pytorch/lib/python3.7/site-packages/paddle/fluid/layers/tensor.py", line 148, in create_parameter
check_type(attr, 'attr', (type(None), ParamAttr), 'create_parameter')
File "/workspace/anaconda3/envs/pytorch/lib/python3.7/site-packages/paddle/fluid/data_feeder.py", line 97, in check_type
(input_name, op_name, expected_type, type(input), extra_message))
TypeError: The type of 'attr' in create_parameter must be (<class 'NoneType'>, <class 'paddle.fluid.param_attr.ParamAttr'>), but received <class 'str'>.
Need to change the generated code to
x2paddle_fc1_bias = fluid.layers.create_parameter(dtype='float32', shape=[128], name='x2paddle_fc1_bias', attr=ParamAttr('x2paddle_fc1_bias'), default_initializer=Constant(0.0))