Пример #1
0
def _get_image_info(features, mode):
    """Calculates the logits and sequence length"""

    image = features['image']
    width = features['width']

    conv_features, sequence_length = model.convnet_layers(image, width, mode)

    logits = model.rnn_layers(conv_features, sequence_length,
                              charset.num_classes())

    return logits, sequence_length
Пример #2
0
def _get_output(rnn_logits, sequence_length, lexicon):
    """Create ops for validation
       predictions: Results of CTC beam search decoding
       log_prob: Score of predictions
    """
    with tf.name_scope("test"):
        if lexicon:
            dict_tensor = _get_dictionary_tensor(lexicon, charset.out_charset)
            predictions, log_prob = tf.nn.ctc_beam_search_decoder_trie(
                rnn_logits,
                sequence_length,
                alphabet_size=charset.num_classes(),
                dictionary=dict_tensor,
                beam_width=128,
                top_paths=1,
                merge_repeated=True)
        else:
            predictions, log_prob = tf.nn.ctc_beam_search_decoder(
                rnn_logits,
                sequence_length,
                beam_width=128,
                top_paths=1,
                merge_repeated=True)
    return predictions, log_prob