Error when create GRUCell with ParamAttr
Created by: xperzy
Basic Info: PaddlePaddle 1.7.0 GPU, Centos, Python 3.7
Model: GRUCell
Issue: Error when create GRUCell with ParamAttr
Details:
When create GRUCell with param_attr, and bias_attr, the source code in Paddle (rnn_impl.py LINE106) creates 2 weights and 2 bias with same ParamAttr, which will occur error:
ValueError: Variable w has been created before. the previous shape is (202, 400); the new shape is (202, 200). They are not matched.
Python Code to create this error:
import numpy as np
import paddle.fluid as fluid
from paddle.fluid.param_attr import ParamAttr
gru_cell = fluid.layers.GRUCell(hidden_size=200,
param_attr=fluid.ParamAttr(name='w'),
bias_attr=fluid.ParamAttr(name='b'),
)
init_h = fluid.layers.fill_constant([1, 200], 'float32', 0.0)
place = fluid.CUDAPlace(0)
exe = fluid.Executor(place)
data_in = fluid.layers.data(name='data_in', shape=[-1, 2], dtype='float32')
out, h = gru_cell(data_in, init_h)
exe.run(fluid.default_startup_program())
test_program = fluid.default_main_program().clone(for_test=True)
sample_data = np.array([0.1, 0.2])[np.newaxis, :]
print(sample_data.shape)
fetch_list=[out.name]
pred = exe.run(test_program,
fetch_list=fetch_list,
feed={'data_in', sample_data})
print(pred)