当前位置: 首页>>代码示例>>Python>>正文


Python decoder.Decoder方法代码示例

本文整理汇总了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]) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:19,代码来源:decoder_test.py

示例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) 
开发者ID:jiali-ms,项目名称:JLM,代码行数:18,代码来源:eval.py

示例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') 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:10,代码来源:decoder_test.py

示例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() 
开发者ID:renqianluo,项目名称:NAO_pytorch,代码行数:42,代码来源:controller.py

示例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() 
开发者ID:antoyang,项目名称:NAS-Benchmark,代码行数:43,代码来源:controller.py

示例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 
开发者ID:johnoneil,项目名称:arib,代码行数:29,代码来源:closed_caption.py

示例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() 
开发者ID:elleryqueenhomels,项目名称:arbitrary_style_transfer,代码行数:5,代码来源:style_transfer_net.py


注:本文中的decoder.Decoder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。