本文整理汇总了Python中decoder.Decoder方法的典型用法代码示例。如果您正苦于以下问题:Python decoder.Decoder方法的具体用法?Python decoder.Decoder怎么用?Python decoder.Decoder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类decoder
的用法示例。
在下文中一共展示了decoder.Decoder方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testCodesFromCTC
# 需要导入模块: import decoder [as 别名]
# 或者: from decoder import Decoder [as 别名]
def testCodesFromCTC(self):
"""Tests that the simple CTC decoder drops nulls and duplicates.
"""
ctc_labels = [9, 9, 9, 1, 9, 2, 2, 3, 9, 9, 0, 0, 1, 9, 1, 9, 9, 9]
decode = decoder.Decoder(filename=None)
non_null_labels = decode._CodesFromCTC(
ctc_labels, merge_dups=False, null_label=9)
self.assertEqual(non_null_labels, [1, 2, 2, 3, 0, 0, 1, 1])
idempotent_labels = decode._CodesFromCTC(
non_null_labels, merge_dups=False, null_label=9)
self.assertEqual(idempotent_labels, non_null_labels)
collapsed_labels = decode._CodesFromCTC(
ctc_labels, merge_dups=True, null_label=9)
self.assertEqual(collapsed_labels, [1, 2, 3, 0, 1, 1])
non_idempotent_labels = decode._CodesFromCTC(
collapsed_labels, merge_dups=True, null_label=9)
self.assertEqual(non_idempotent_labels, [1, 2, 3, 0, 1])
示例2: __init__
# 需要导入模块: import decoder [as 别名]
# 或者: from decoder import Decoder [as 别名]
def __init__(self):
self.config = json.loads(open(os.path.join(experiment_path, str(args.experiment_id), 'config.json'), 'rt').read())
if self.config['char_rnn']:
self.vocab = CharVocab(self.config['vocab_size'])
else:
self.vocab = Vocab(self.config['vocab_size'])
self.w2i = self.vocab.w2i
if args.use_ngram:
self.decoder = NGramDecoder(experiment_id=args.experiment_id, ngram_order=args.ngram_order)
elif self.config['char_rnn']:
self.decoder = CharRNNDecoder(experiment_id=args.experiment_id, comp=args.comp)
elif args.dynamic_decoding:
self.decoder = DynamicDecoder(experiment_id=args.experiment_id, comp=args.comp)
else:
self.decoder = Decoder(experiment_id=args.experiment_id, comp=args.comp)
示例3: testStringFromCTC
# 需要导入模块: import decoder [as 别名]
# 或者: from decoder import Decoder [as 别名]
def testStringFromCTC(self):
"""Tests that the decoder can decode sequences including multi-codes.
"""
# - f - a r - m(1/2)m -junk sp b a r - n -
ctc_labels = [9, 6, 9, 1, 3, 9, 4, 9, 5, 5, 9, 5, 0, 2, 1, 3, 9, 4, 9]
decode = decoder.Decoder(filename=_testdata('charset_size_10.txt'))
text = decode.StringFromCTC(ctc_labels, merge_dups=True, null_label=9)
self.assertEqual(text, 'farm barn')
示例4: __init__
# 需要导入模块: import decoder [as 别名]
# 或者: from decoder import Decoder [as 别名]
def __init__(self,
encoder_layers,
encoder_vocab_size,
encoder_hidden_size,
encoder_dropout,
encoder_length,
source_length,
encoder_emb_size,
mlp_layers,
mlp_hidden_size,
mlp_dropout,
decoder_layers,
decoder_vocab_size,
decoder_hidden_size,
decoder_dropout,
decoder_length,
):
super(NAO, self).__init__()
self.encoder = Encoder(
encoder_layers,
encoder_vocab_size,
encoder_hidden_size,
encoder_dropout,
encoder_length,
source_length,
encoder_emb_size,
mlp_layers,
mlp_hidden_size,
mlp_dropout,
)
self.decoder = Decoder(
decoder_layers,
decoder_vocab_size,
decoder_hidden_size,
decoder_dropout,
decoder_length,
encoder_length
)
self.flatten_parameters()
示例5: __init__
# 需要导入模块: import decoder [as 别名]
# 或者: from decoder import Decoder [as 别名]
def __init__(self,
encoder_layers,
encoder_vocab_size,
encoder_hidden_size,
encoder_dropout,
encoder_length,
source_length,
encoder_emb_size,
mlp_layers,
mlp_hidden_size,
mlp_dropout,
decoder_layers,
decoder_vocab_size,
decoder_hidden_size,
decoder_dropout,
decoder_length,
):
super(NAO, self).__init__()
self.encoder = Encoder(
encoder_layers,
encoder_vocab_size,
encoder_hidden_size,
encoder_dropout,
encoder_length,
source_length,
encoder_emb_size,
mlp_layers,
mlp_hidden_size,
mlp_dropout,
)
self.decoder = Decoder(
decoder_layers,
decoder_vocab_size,
decoder_hidden_size,
decoder_dropout,
decoder_length,
encoder_length
)
self.init_parameters()
self.flatten_parameters()
示例6: parse_contents
# 需要导入模块: import decoder [as 别名]
# 或者: from decoder import Decoder [as 别名]
def parse_contents(f, bytes_to_read):
'''
Do complex reading of caption data from binary file.
Return a list of statements and characters
'''
if DEBUG:
print 'going to read {bytes} bytes in binary file caption statement.'.format(bytes=bytes_to_read)
statements = []
bytes_read = 0
#TODO: Check to see if decoder state is carred between packet processing
#currently recreating the decoder (and therefore resetting its state)
#on every packet paylod processing. This may be incorrect
decoder = Decoder()
line = ''
while bytes_read<bytes_to_read:
statement = decoder.decode(f)
if statement:
bytes_read += len(statement)
statements.append(statement)
#if isinstance(statement, code_set.Kanji) or isinstance(statement, code_set.Alphanumeric) \
# or isinstance(statement, code_set.Hiragana) or isinstance(statement, code_set.Katakana):
# if DEBUG:
# print statement #just dump to stdout for now
# line += str(statement)
#if len(line)>0:
# print '{l}\n'.format(l=line)
return statements
示例7: __init__
# 需要导入模块: import decoder [as 别名]
# 或者: from decoder import Decoder [as 别名]
def __init__(self, encoder_weights_path):
self.encoder = Encoder(encoder_weights_path)
self.decoder = Decoder()