提交 f1b6a68b 编写于 作者: G guosheng

Add some apis in hapi.text into example code white list.

test=develop
上级 a13654b9
...@@ -222,6 +222,19 @@ class BasicLSTMCell(RNNCell): ...@@ -222,6 +222,19 @@ class BasicLSTMCell(RNNCell):
forget_bias(float, optional): forget bias used when computing forget gate. forget_bias(float, optional): forget bias used when computing forget gate.
Default 1.0 Default 1.0
dtype(string, optional): The data type used in this cell. Default float32. dtype(string, optional): The data type used in this cell. Default float32.
Examples:
.. code-block:: python
import paddle
import paddle.fluid as fluid
from paddle.incubate.hapi.text import BasicLSTMCell, RNN
inputs = paddle.rand((2, 4, 32))
cell = BasicLSTMCell(input_size=32, hidden_size=64)
rnn = RNN(cell=cell)
outputs, _ = rnn(inputs) # [2, 4, 64]
""" """
def __init__(self, def __init__(self,
...@@ -339,6 +352,19 @@ class BasicGRUCell(RNNCell): ...@@ -339,6 +352,19 @@ class BasicGRUCell(RNNCell):
GRU, that is :math:`act_c` in the formula. Default: None, GRU, that is :math:`act_c` in the formula. Default: None,
representing for 'fluid.layers.tanh'. representing for 'fluid.layers.tanh'.
dtype(string, optional): The data type used in this cell. Default float32. dtype(string, optional): The data type used in this cell. Default float32.
Examples:
.. code-block:: python
import paddle
import paddle.fluid as fluid
from paddle.incubate.hapi.text import BasicGRUCell, RNN
inputs = paddle.rand((2, 4, 32))
cell = BasicGRUCell(input_size=32, hidden_size=64)
rnn = RNN(cell=cell)
outputs, _ = rnn(inputs) # [2, 4, 64]
""" """
def __init__(self, def __init__(self,
...@@ -1787,7 +1813,7 @@ class DynamicDecode(Layer): ...@@ -1787,7 +1813,7 @@ class DynamicDecode(Layer):
trg_embeder = fluid.dygraph.Embedding(size=[vocab_size, d_model]) trg_embeder = fluid.dygraph.Embedding(size=[vocab_size, d_model])
output_layer = fluid.dygraph.Linear(d_model, vocab_size) output_layer = fluid.dygraph.Linear(d_model, vocab_size)
cell = StackedLSTMCell(input_size=d_model, hidden_size=d_model) cell = StackedLSTMCell(input_size=d_model, hidden_size=d_model)
decoder = BeamSearchDecoder(decoder_cell, decoder = BeamSearchDecoder(cell,
start_token=0, start_token=0,
end_token=1, end_token=1,
beam_size=4, beam_size=4,
...@@ -3665,6 +3691,7 @@ class CRFDecoding(Layer): ...@@ -3665,6 +3691,7 @@ class CRFDecoding(Layer):
.. code-block:: python .. code-block:: python
import numpy as np
import paddle import paddle
import paddle.fluid as fluid import paddle.fluid as fluid
from paddle.incubate.hapi.text import CRFDecoding from paddle.incubate.hapi.text import CRFDecoding
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册