easy_vision.python.core.decoders

easy_vision.python.core.decoders.decoder

class easy_vision.python.core.decoders.decoder.Decoder(config, is_training, scope='Decoder')[source]

Bases: object

Abstract class from which all decoders must inherit.

__init__(config, is_training, scope='Decoder')[source]

x.__init__(…) initializes x; see help(type(x)) for signature

decode(feature_dict, label_dict=None)[source]

Decode encode outputs to decode results :param feature_dict: a dict of feature tensors :param label_dict: a dict of label tensors, used when training

Returns:a dict of decode results
Return type:prediction_dict

easy_vision.python.core.decoders.fc_decoders

class easy_vision.python.core.decoders.fc_decoders.FullyConnectedCTCDecoder(config, vocab_size, time_major, is_training, scope='CTCDecoder')[source]

Bases: easy_vision.python.core.decoders.decoder.Decoder

__init__(config, vocab_size, time_major, is_training, scope='CTCDecoder')[source]

x.__init__(…) initializes x; see help(type(x)) for signature

easy_vision.python.core.decoders.rnn_decoders

class easy_vision.python.core.decoders.rnn_decoders.RNNDecoderWithAttention(config, vocab_size, time_major=True, is_training=True, scope='AttentionDecoder')[source]

Bases: easy_vision.python.core.decoders.decoder.Decoder

Typical RNN decoder with attention mechanism.

__init__(config, vocab_size, time_major=True, is_training=True, scope='AttentionDecoder')[source]
Parameters:
  • config – protos.decoder_pb2.RNNDecoderWithAttention
  • vocab_size – the number of characters
  • time_major – if time major, input feature must be [time, batch, channel]
  • is_training – train or not(eval/predict)
  • scope – variable scope

easy_vision.python.core.decoders.transformer_decoder

class easy_vision.python.core.decoders.transformer_decoder.TransformerDecoder(config, vocab_size, is_training=True, scope='TransformerDecoder')[source]

Bases: easy_vision.python.core.decoders.decoder.Decoder

Transformer model decoder

__init__(config, vocab_size, is_training=True, scope='TransformerDecoder')[source]
Parameters:
  • config – protos.decoder_pb2.TransformerDecoder
  • vocab_size – the number of characters
  • time_major – if time major, input feature must be [time, batch, channel]
  • is_training – train or not(eval/predict)
  • scope – variable scope
decode_pass(targets, encoder_outputs, inputs_attention_bias)[source]

Generate logits for each value in the target sequence.

Parameters:
  • targets – target values for the output sequence. int tensor with shape [batch_size, target_length]
  • encoder_outputs – continuous representation of input sequence. float tensor with shape [batch_size, input_length, hidden_size]
  • inputs_attention_bias – float tensor with shape [batch_size, 1, 1, input_length]
Returns:

float32 tensor with shape [batch_size, target_length, vocab_size]

predict(encoder_outputs, encoder_decoder_attention_bias)[source]

Return predicted sequence.