Paddle icon indicating copy to clipboard operation
Paddle copied to clipboard

feed initial hidden state to dynamic_gru cause an error

Open zhoukunsheng opened this issue 8 years ago • 2 comments

Paddle version: 0.15.0 environment: CPU, use fluid API

error infomation: Traceback (most recent call last): File "train.py", line 281, in train_net() File "train.py", line 277, in train_net model_dir="model") File "train.py", line 165, in train bi_gru = gru(item_merge, 32, True, user_fc) File "train.py", line 97, in gru h_0=h_0) File "/anaconda2/lib/python2.7/site-packages/paddle/fluid/layers/nn.py", line 680, in dynamic_gru if h_0 != None: File "/anaconda2/lib/python2.7/site-packages/paddle/fluid/layers/math_op_patch.py", line 118, in impl self.block, value=other_var, dtype=lhs_dtype) File "/anaconda2/lib/python2.7/site-packages/paddle/fluid/layers/math_op_patch.py", line 49, in create_scalar return create_tensor(block, value, dtype, shape=[1]) File "/anaconda2/lib/python2.7/site-packages/paddle/fluid/layers/math_op_patch.py", line 34, in create_tensor value = float(value) TypeError: float() argument must be a string or a number

modify ~/anaconda2/lib/python2.7/site-packages/paddle/fluid/layers/nn.py:680 from "if h_0 != None:" to "if h_0: " seems fix the problem.

zhoukunsheng avatar Sep 28 '18 02:09 zhoukunsheng

建议贴一下完整代码,以目前有限的log看,应该是你把某个数值设置为None了。

wanghaoshuang avatar Sep 29 '18 05:09 wanghaoshuang

您好,此issue若已经解决,我们将于三天内关闭。若在关闭后您仍需跟进提问,可重新开启此问题, 我们将在24小时内回复您。因关闭带来的不便我们深表歉意,请您谅解~感谢您对PaddlePaddle的支持!

lucywsq avatar Oct 26 '18 07:10 lucywsq