From f1b6a68bf0e7f40e6f2d1ff5cf1da22c0910e3a0 Mon Sep 17 00:00:00 2001 From: guosheng Date: Wed, 13 May 2020 04:23:32 +0800 Subject: [PATCH] Add some apis in hapi.text into example code white list. test=develop --- hapi/text/text.py | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/hapi/text/text.py b/hapi/text/text.py index 2eef453..97803cb 100644 --- a/hapi/text/text.py +++ b/hapi/text/text.py @@ -222,6 +222,19 @@ class BasicLSTMCell(RNNCell): forget_bias(float, optional): forget bias used when computing forget gate. Default 1.0 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, @@ -339,6 +352,19 @@ class BasicGRUCell(RNNCell): GRU, that is :math:`act_c` in the formula. Default: None, representing for 'fluid.layers.tanh'. 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, @@ -1787,7 +1813,7 @@ class DynamicDecode(Layer): trg_embeder = fluid.dygraph.Embedding(size=[vocab_size, d_model]) output_layer = fluid.dygraph.Linear(d_model, vocab_size) cell = StackedLSTMCell(input_size=d_model, hidden_size=d_model) - decoder = BeamSearchDecoder(decoder_cell, + decoder = BeamSearchDecoder(cell, start_token=0, end_token=1, beam_size=4, @@ -3665,6 +3691,7 @@ class CRFDecoding(Layer): .. code-block:: python + import numpy as np import paddle import paddle.fluid as fluid from paddle.incubate.hapi.text import CRFDecoding -- GitLab