Nabu-asr
Public Member Functions | Public Attributes | List of all members
nabu.neuralnetworks.components.beam_search_decoder.BeamSearchDecoder Class Reference

the beam search decode More...

Inheritance diagram for nabu.neuralnetworks.components.beam_search_decoder.BeamSearchDecoder:

Public Member Functions

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...
 

Public Attributes

 cell
 
 embedding
 
 start_tokens
 
 end_token
 
 initial_state
 
 beam_width
 
 output_layer
 
 length_penalty_weight
 

Detailed Description

the beam search decode

Constructor & Destructor Documentation

§ __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
cellAn RNNCell instance.
embeddingA callable that takes a vector tensor of ids (argmax ids), or the params argument for embedding_lookup.
start_tokensint32 vector shaped [batch_size], the start
tokens.
end_tokenint32 scalar, the token that marks end of decoding.
initial_stateA (possibly nested tuple of...) tensors and
TensorArrays.
beam_widthPython 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_weightFloat weight to penalize length. Disabled with 0.0.
temperaturea temperature to apply before the softmax to smooth or sharpen the probabilities. High temperature means a smooth
distribution

Member Function Documentation

§ finalize()

def nabu.neuralnetworks.components.beam_search_decoder.BeamSearchDecoder.finalize (   self,
  outputs,
  final_state,
  sequence_lengths 
)

Finalize and return the predicted_ids.

Parameters
outputsAn instance of BeamSearchDecoderOutput.
final_stateAn instance of BeamSearchState.
sequence_lengthsAn int64 tensor shaped [batch_size, beam_width]. The sequence lengths
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
nameName 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
timeScalar int32 tensor. Current step number.
inputsRNNCell input (possibly nested tuple of) tensor[s] for this time step.
stateRNNCell state (possibly nested tuple of) tensor[s] from previous time step.
nameName 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: