TrainingDecoder¶
- class paddle.fluid.contrib.decoder.beam_search_decoder. TrainingDecoder ( state_cell, name=None ) [source]
- 
         A decoder that can only be used for training. The decoder could be initialized with a StateCell object. The computation within the RNN cell could be defined with decoder’s block. - Parameters
- 
           - state_cell (StateCell) – A StateCell object that handles the input and state variables. 
- name (str) – The name of this decoder. Default None. 
 
- Returns
- 
           The initialized TrainingDecoder object. 
- Return type
- 
           TrainingDecoder 
 Examples - 
            
           block
           (
           )
           block¶
- 
           Define the behavior of the decoder for each RNN time step. 
 - 
            
           step_input
           (
           x
           )
           step_input¶
- 
           Set the input variable as a step input to the RNN cell. For example, in machine translation, each time step we read one word from the target sentences, then the target sentence is a step input to the RNN cell. - Parameters
- 
             x (Variable) – the variable to be used as step input. 
- Returns
- 
             The variable as input of current step. 
- Return type
- 
             Variable 
 Examples: .. code-block:: python current_word = decoder.step_input(trg_embedding) 
 - 
            
           static_input
           (
           x
           )
           static_input¶
- 
           Set the input variable as a static input of RNN cell. In contrast to step input, this variable will be used as a whole within the RNN decode loop and will not be scattered into time steps. - Parameters
- 
             x (Variable) – the variable to be used as static input. 
- Returns
- 
             The variable as input of current step. 
- Return type
- 
             Variable 
 Examples: .. code-block:: python encoder_vec = decoder.static_input(encoded_vector) 
 - 
            
           output
           (
           *outputs
           )
           output¶
- 
           Set the output variable of the RNN cell. - Parameters
- 
             *outputs (Variables) – a series of variables that treated as output of the RNN cell. 
 Examples: .. code-block:: python - out = fluid.layers.fc(input=h,
- 
               size=32, bias_attr=True, act=’softmax’) 
 decoder.output(out) 
 
