the beam search decode
More...
|
def | batch_size (self) |
| the batch size
|
|
def | output_size (self) |
| the output size (empty)
|
|
def | output_dtype (self) |
| the output dtype (empty)
|
|
def | __init__ (self, cell, embedding, start_tokens, end_token, initial_state, beam_width, output_layer=None, length_penalty_weight=0.0, temperature=1.0) |
| constructor More...
|
|
def | initialize (self, name=None) |
| Called before any decoding iterations. More...
|
|
def | step (self, time, inputs, state, name=None) |
| Called per step of decoding (but only once for dynamic decoding). More...
|
|
def | finalize (self, outputs, final_state, sequence_lengths) |
| Finalize and return the predicted_ids. More...
|
|
|
| cell |
|
| embedding |
|
| start_tokens |
|
| end_token |
|
| initial_state |
|
| beam_width |
|
| output_layer |
|
| length_penalty_weight |
|
§ __init__()
def nabu.neuralnetworks.components.beam_search_decoder.BeamSearchDecoder.__init__ |
( |
|
self, |
|
|
|
cell, |
|
|
|
embedding, |
|
|
|
start_tokens, |
|
|
|
end_token, |
|
|
|
initial_state, |
|
|
|
beam_width, |
|
|
|
output_layer = None , |
|
|
|
length_penalty_weight = 0.0 , |
|
|
|
temperature = 1.0 |
|
) |
| |
constructor
- Parameters
-
cell | An RNNCell instance. |
embedding | A callable that takes a vector tensor of ids (argmax ids), or the params argument for embedding_lookup . |
start_tokens | int32 vector shaped [batch_size] , the start |
tokens. | |
end_token | int32 scalar, the token that marks end of decoding. |
initial_state | A (possibly nested tuple of...) tensors and |
TensorArrays. | |
beam_width | Python integer, the number of beams. |
output_layer | (Optional) An instance of tf.layers.Layer , i.e., tf.layers.Dense . Optional layer to apply to the RNN output prior to storing the result or sampling. |
length_penalty_weight | Float weight to penalize length. Disabled with 0.0. |
temperature | a temperature to apply before the softmax to smooth or sharpen the probabilities. High temperature means a smooth |
distribution | |
§ finalize()
def nabu.neuralnetworks.components.beam_search_decoder.BeamSearchDecoder.finalize |
( |
|
self, |
|
|
|
outputs, |
|
|
|
final_state, |
|
|
|
sequence_lengths |
|
) |
| |
Finalize and return the predicted_ids.
- Parameters
-
- Returns
-
§ initialize()
def nabu.neuralnetworks.components.beam_search_decoder.BeamSearchDecoder.initialize |
( |
|
self, |
|
|
|
name = None |
|
) |
| |
Called before any decoding iterations.
This methods must compute initial input values and initial state.
- Parameters
-
name | Name scope for any created operations. |
- Returns
(finished, initial_inputs, initial_state)
: initial values of 'finished' flags, inputs and state.
§ step()
def nabu.neuralnetworks.components.beam_search_decoder.BeamSearchDecoder.step |
( |
|
self, |
|
|
|
time, |
|
|
|
inputs, |
|
|
|
state, |
|
|
|
name = None |
|
) |
| |
Called per step of decoding (but only once for dynamic decoding).
- Parameters
-
time | Scalar int32 tensor. Current step number. |
inputs | RNNCell input (possibly nested tuple of) tensor[s] for this time step. |
state | RNNCell state (possibly nested tuple of) tensor[s] from previous time step. |
name | Name scope for any created operations. |
- Returns
(outputs, next_state, next_inputs, finished)
: outputs
is an object containing the decoder output, next_state
is a (structure of) state tensors and TensorArrays, next_inputs
is the tensor that should be used as input for the next step, finished
is a boolean tensor telling whether the sequence is complete, for each sequence in the batch.
The documentation for this class was generated from the following file:
- components/beam_search_decoder.py