未验证 提交 d7da19ba 编写于 作者: G Guo Sheng 提交者: GitHub

Update the code sample in cn doc of dynamic_gru and gru_unit. (#1607)

上级 04b012c2
...@@ -60,9 +60,11 @@ dynamic_gru ...@@ -60,9 +60,11 @@ dynamic_gru
import paddle.fluid as fluid import paddle.fluid as fluid
dict_dim, emb_dim = 128, 64 dict_dim, emb_dim = 128, 64
data = fluid.layers.data(name='sequence', shape=[1], data = fluid.data(name='sequence',
dtype='int32', lod_level=1) shape=[None],
emb = fluid.layers.embedding(input=data, size=[dict_dim, emb_dim]) dtype='int64',
lod_level=1)
emb = fluid.embedding(input=data, size=[dict_dim, emb_dim])
hidden_dim = 512 hidden_dim = 512
x = fluid.layers.fc(input=emb, size=hidden_dim * 3) x = fluid.layers.fc(input=emb, size=hidden_dim * 3)
hidden = fluid.layers.dynamic_gru(input=x, size=hidden_dim) hidden = fluid.layers.dynamic_gru(input=x, size=hidden_dim)
......
...@@ -57,12 +57,12 @@ Gated Recurrent Unit(GRU)循环神经网络计算单元。该OP用于完成 ...@@ -57,12 +57,12 @@ Gated Recurrent Unit(GRU)循环神经网络计算单元。该OP用于完成
import paddle.fluid as fluid import paddle.fluid as fluid
dict_dim, emb_dim = 128, 64 dict_dim, emb_dim = 128, 64
data = fluid.layers.data(name='step_data', shape=[1], dtype='int32') data = fluid.data(name='step_data', shape=[None], dtype='int64')
emb = fluid.layers.embedding(input=data, size=[dict_dim, emb_dim]) emb = fluid.embedding(input=data, size=[dict_dim, emb_dim])
hidden_dim = 512 hidden_dim = 512
x = fluid.layers.fc(input=emb, size=hidden_dim * 3) x = fluid.layers.fc(input=emb, size=hidden_dim * 3)
pre_hidden = fluid.layers.data( pre_hidden = fluid.data(
name='pre_hidden', shape=[hidden_dim], dtype='float32') name='pre_hidden', shape=[None, hidden_dim], dtype='float32')
hidden = fluid.layers.gru_unit( hidden = fluid.layers.gru_unit(
input=x, hidden=pre_hidden, size=hidden_dim * 3) input=x, hidden=pre_hidden, size=hidden_dim * 3)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册