internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: PaddlePaddle/models

Issue:
resnet模型配置的问题
目前resnet的配置有一些问题，可见 https://github.com/PaddlePaddle/models/issues/308#issuecomment-331384031


Discussion:

Resolving patch:
diff --git a/image_classification/resnet.py b/image_classification/resnet.py
--- a/image_classification/resnet.py
+++ b/image_classification/resnet.py
@@ -22,24 +22,24 @@ def conv_bn_layer(input,
     return paddle.layer.batch_norm(input=tmp, act=active_type)
 
 
-def shortcut(input, ch_in, ch_out, stride):
-    if ch_in != ch_out:
+def shortcut(input, ch_out, stride):
+    if input.num_filters != ch_out:
         return conv_bn_layer(input, ch_out, 1, stride, 0,
                              paddle.activation.Linear())
     else:
         return input
 
 
-def basicblock(input, ch_in, ch_out, stride):
-    short = shortcut(input, ch_in, ch_out, stride)
+def basicblock(input, ch_out, stride):
+    short = shortcut(input, ch_out, stride)
     conv1 = conv_bn_layer(input, ch_out, 3, stride, 1)
     conv2 = conv_bn_layer(conv1, ch_out, 3, 1, 1, paddle.activation.Linear())
     return paddle.layer.addto(
         input=[short, conv2], act=paddle.activation.Relu())
 
 
-def bottleneck(input, ch_in, ch_out, stride):
-    short = shortcut(input, ch_in, ch_out * 4, stride)
+def bottleneck(input, ch_out, stride):
+    short = shortcut(input, ch_out * 4, stride)
     conv1 = conv_bn_layer(input, ch_out, 1, stride, 0)
     conv2 = conv_bn_layer(conv1, ch_out, 3, 1, 1)
     conv3 = conv_bn_layer(conv2, ch_out * 4, 1, 1, 0,
@@ -48,10 +48,10 @@ def bottleneck(input, ch_in, ch_out, stride):
         input=[short, conv3], act=paddle.activation.Relu())
 
 
-def layer_warp(block_func, input, ch_in, ch_out, count, stride):
-    conv = block_func(input, ch_in, ch_out, stride)
+def layer_warp(block_func, input, ch_out, count, stride):
+    conv = block_func(input, ch_out, stride)
     for i in range(1, count):
-        conv = block_func(conv, ch_out, ch_out, 1)
+        conv = block_func(conv, ch_out, 1)
     return conv
 
 
@@ -67,10 +67,10 @@ def resnet_imagenet(input, class_dim, depth=50):
     conv1 = conv_bn_layer(
         input, ch_in=3, ch_out=64, filter_size=7, stride=2, padding=3)
     pool1 = paddle.layer.img_pool(input=conv1, pool_size=3, stride=2)
-    res1 = layer_warp(block_func, pool1, 64, 64, stages[0], 1)
-    res2 = layer_warp(block_func, res1, 64, 128, stages[1], 2)
-    res3 = layer_warp(block_func, res2, 128, 256, stages[2], 2)
-    res4 = layer_warp(block_func, res3, 256, 512, stages[3], 2)
+    res1 = layer_warp(block_func, pool1, 64, stages[0], 1)
+    res2 = layer_warp(block_func, res1, 128, stages[1], 2)
+    res3 = layer_warp(block_func, res2, 256, stages[2], 2)
+    res4 = layer_warp(block_func, res3, 512, stages[3], 2)
     pool2 = paddle.layer.img_pool(
         input=res4, pool_size=7, stride=1, pool_type=paddle.pooling.Avg())
     out = paddle.layer.fc(


Test patch:
Repository: PaddlePaddle/models

Issue:
Fix bugs for model_utils/model.py
Always print 0 for ValidataionCost


Discussion:

Resolving patch:
diff --git a/deep_speech_2/model_utils/model.py b/deep_speech_2/model_utils/model.py
--- a/deep_speech_2/model_utils/model.py
+++ b/deep_speech_2/model_utils/model.py
@@ -129,9 +129,10 @@ def event_handler(event):
                 else:
                     result = trainer.test(
                         reader=dev_batch_reader, feeding=feeding_dict)
-                    print("\n------- Time: %d sec,  Pass: %d, "
-                          "ValidationCost: %s" %
-                          (time.time() - start_time, event.pass_id, 0))
+                    print(
+                        "\n------- Time: %d sec,  Pass: %d, "
+                        "ValidationCost: %s" %
+                        (time.time() - start_time, event.pass_id, result.cost))
                 output_model_path = os.path.join(
                     output_model_dir, "params.pass-%d.tar.gz" % event.pass_id)
                 with gzip.open(output_model_path, 'w') as f:


Test patch:
Repository: PaddlePaddle/models

Issue:
Enable the log of gradient clipping in training



Discussion:

Resolving patch:
diff --git a/deep_speech_2/decoders/swig_wrapper.py b/deep_speech_2/decoders/swig_wrapper.py
--- a/deep_speech_2/decoders/swig_wrapper.py
+++ b/deep_speech_2/decoders/swig_wrapper.py
@@ -35,7 +35,8 @@ def ctc_greedy_decoder(probs_seq, vocabulary):
     :return: Decoding result string.
     :rtype: basestring
     """
-    return swig_decoders.ctc_greedy_decoder(probs_seq.tolist(), vocabulary)
+    result = swig_decoders.ctc_greedy_decoder(probs_seq.tolist(), vocabulary)
+    return result.decode('utf-8')
 
 
 def ctc_beam_search_decoder(probs_seq,
@@ -69,9 +70,11 @@ def ctc_beam_search_decoder(probs_seq,
              results, in descending order of the probability.
     :rtype: list
     """
-    return swig_decoders.ctc_beam_search_decoder(probs_seq.tolist(), vocabulary,
-                                                 beam_size, cutoff_prob,
-                                                 cutoff_top_n, ext_scoring_func)
+    beam_results = swig_decoders.ctc_beam_search_decoder(
+        probs_seq.tolist(), vocabulary, beam_size, cutoff_prob, cutoff_top_n,
+        ext_scoring_func)
+    beam_results = [(res[0], res[1].decode('utf-8')) for res in beam_results]
+    return beam_results
 
 
 def ctc_beam_search_decoder_batch(probs_split,
@@ -111,6 +114,11 @@ def ctc_beam_search_decoder_batch(probs_split,
     """
     probs_split = [probs_seq.tolist() for probs_seq in probs_split]
 
-    return swig_decoders.ctc_beam_search_decoder_batch(
+    batch_beam_results = swig_decoders.ctc_beam_search_decoder_batch(
         probs_split, vocabulary, beam_size, num_processes, cutoff_prob,
         cutoff_top_n, ext_scoring_func)
+    batch_beam_results = [
+        [(res[0], res[1].decode("utf-8")) for res in beam_results]
+        for beam_results in batch_beam_results
+    ]
+    return batch_beam_results
diff --git a/deep_speech_2/train.py b/deep_speech_2/train.py
--- a/deep_speech_2/train.py
+++ b/deep_speech_2/train.py
@@ -118,7 +118,9 @@ def train():
 
 def main():
     print_arguments(args)
-    paddle.init(use_gpu=args.use_gpu, trainer_count=args.trainer_count)
+    paddle.init(use_gpu=args.use_gpu,
+                trainer_count=args.trainer_count,
+                log_clipping=True)
     train()
 
 


Test patch:
Repository: PaddlePaddle/models

Issue:
DS2's tools/compute_mean_std.py failed with seqbin data



Discussion:

Resolving patch:
diff --git a/deep_speech_2/data_utils/audio.py b/deep_speech_2/data_utils/audio.py
--- a/deep_speech_2/data_utils/audio.py
+++ b/deep_speech_2/data_utils/audio.py
@@ -65,8 +65,11 @@ def from_file(cls, file):
         :return: Audio segment instance.
         :rtype: AudioSegment
         """
-        samples, sample_rate = soundfile.read(file, dtype='float32')
-        return cls(samples, sample_rate)
+        if isinstance(file, basestring) and re.findall(r".seqbin_\d+$", file):
+            return cls.from_sequence_file(file)
+        else:
+            samples, sample_rate = soundfile.read(file, dtype='float32')
+            return cls(samples, sample_rate)
 
     @classmethod
     def slice_from_file(cls, file, start=None, end=None):
diff --git a/deep_speech_2/data_utils/data.py b/deep_speech_2/data_utils/data.py
--- a/deep_speech_2/data_utils/data.py
+++ b/deep_speech_2/data_utils/data.py
@@ -7,7 +7,6 @@
 
 import random
 import tarfile
-import re
 import multiprocessing
 import numpy as np
 import paddle.v2 as paddle
@@ -105,9 +104,6 @@ def process_utterance(self, filename, transcript):
         if filename.startswith('tar:'):
             speech_segment = SpeechSegment.from_file(
                 self._subfile_from_tar(filename), transcript)
-        elif re.findall(r".seqbin_\d+$", filename):
-            speech_segment = SpeechSegment.from_sequence_file(filename,
-                                                              transcript)
         else:
             speech_segment = SpeechSegment.from_file(filename, transcript)
         self._augmentation_pipeline.transform_audio(speech_segment)
diff --git a/deep_speech_2/data_utils/speech.py b/deep_speech_2/data_utils/speech.py
--- a/deep_speech_2/data_utils/speech.py
+++ b/deep_speech_2/data_utils/speech.py
@@ -50,20 +50,6 @@ def from_file(cls, filepath, transcript):
         audio = AudioSegment.from_file(filepath)
         return cls(audio.samples, audio.sample_rate, transcript)
 
-    @classmethod
-    def from_sequence_file(cls, filepath, transcript):
-        """Create speech segment from sequence file and transcript.
-        
-        :param filepath: Filepath of sequence file.
-        :type filepath: basestring
-        :param transcript: Transcript text for the speech.
-        :type transript: basestring
-        :return: Speech segment instance.
-        :rtype: SpeechSegment
-        """
-        audio = AudioSegment.from_sequence_file(filepath)
-        return cls(audio.samples, audio.sample_rate, transcript)
-
     @classmethod
     def from_bytes(cls, bytes, transcript):
         """Create speech segment from a byte string and corresponding


Test patch:
Repository: PaddlePaddle/models

Issue:
使用 generate_sequence_by_rnn_lm 进行train的时候报错
在 generate_sequence_by_rnn_lm 这个模型下运行 train.py 的时候，当测试文件的路径不存在的时候会报错。错误的原因是把conf写成了config。错误行数是train.py 的112行


Discussion:

Resolving patch:
diff --git a/generate_sequence_by_rnn_lm/train.py b/generate_sequence_by_rnn_lm/train.py
--- a/generate_sequence_by_rnn_lm/train.py
+++ b/generate_sequence_by_rnn_lm/train.py
@@ -109,7 +109,7 @@ def main():
         test_reader = paddle.batch(
             paddle.reader.shuffle(
                 reader.rnn_reader(**reader_args), buf_size=65536),
-            batch_size=config.batch_size)
+            batch_size=conf.batch_size)
 
     train(
         topology=cost,


Test patch:
Repository: PaddlePaddle/models

Issue:
In ds2, subprocesses quit abnormally when main process quits.



Discussion:

Resolving patch:
diff --git a/deep_speech_2/data_utils/data.py b/deep_speech_2/data_utils/data.py
--- a/deep_speech_2/data_utils/data.py
+++ b/deep_speech_2/data_utils/data.py
@@ -11,6 +11,7 @@
 import numpy as np
 import paddle.v2 as paddle
 from threading import local
+import atexit
 from data_utils.utility import read_manifest
 from data_utils.utility import xmap_readers_mp
 from data_utils.augmentor.augmentation import AugmentationPipeline
@@ -274,13 +275,18 @@ def reader():
             for instance in manifest:
                 yield instance
 
-        return xmap_readers_mp(
+        reader, cleanup_callback = xmap_readers_mp(
             lambda instance: self.process_utterance(instance["audio_filepath"], instance["text"]),
             reader,
             self._num_threads,
             4096,
             order=True)
 
+        # register callback to main process
+        atexit.register(cleanup_callback)
+
+        return reader
+
     def _padding_batch(self, batch, padding_to=-1, flatten=False):
         """
         Padding audio features with zeros to make them have the same shape (or
diff --git a/deep_speech_2/data_utils/utility.py b/deep_speech_2/data_utils/utility.py
--- a/deep_speech_2/data_utils/utility.py
+++ b/deep_speech_2/data_utils/utility.py
@@ -138,6 +138,10 @@ def flush_worker(in_queue, out_queue):
                 out_queue.put(sample)
         out_queue.put(end_flag)
 
+    def cleanup():
+        # kill all sub process and threads
+        os._exit(0)
+
     def xreader():
         # prepare shared memory
         manager = Manager()
@@ -174,4 +178,4 @@ def xreader():
             yield sample
             sample = flush_queue.get()
 
-    return xreader
+    return xreader, cleanup


Test patch:
Repository: PaddlePaddle/models

Issue:
Adapt tuning script to padding removing #444



Discussion:

Resolving patch:
diff --git a/deep_speech_2/tools/tune.py b/deep_speech_2/tools/tune.py
--- a/deep_speech_2/tools/tune.py
+++ b/deep_speech_2/tools/tune.py
@@ -88,7 +88,8 @@ def tune():
         augmentation_config='{}',
         specgram_type=args.specgram_type,
         num_threads=args.num_proc_data,
-        keep_transcription_text=True)
+        keep_transcription_text=True,
+        num_conv_layers=args.num_conv_layers)
 
     audio_data = paddle.layer.data(
         name="audio_spectrogram",
@@ -96,10 +97,25 @@ def tune():
     text_data = paddle.layer.data(
         name="transcript_text",
         type=paddle.data_type.integer_value_sequence(data_generator.vocab_size))
+    seq_offset_data = paddle.layer.data(
+        name='sequence_offset',
+        type=paddle.data_type.integer_value_sequence(1))
+    seq_len_data = paddle.layer.data(
+        name='sequence_length',
+        type=paddle.data_type.integer_value_sequence(1))
+    index_range_datas = []
+    for i in xrange(args.num_rnn_layers):
+        index_range_datas.append(
+            paddle.layer.data(
+                name='conv%d_index_range' % i,
+                type=paddle.data_type.dense_vector(6)))
 
     output_probs, _ = deep_speech_v2_network(
         audio_data=audio_data,
         text_data=text_data,
+        seq_offset_data=seq_offset_data,
+        seq_len_data=seq_len_data,
+        index_range_datas=index_range_datas,
         dict_size=data_generator.vocab_size,
         num_conv_layers=args.num_conv_layers,
         num_rnn_layers=args.num_rnn_layers,
@@ -156,15 +172,17 @@ def tune():
     for infer_data in batch_reader():
         if (args.num_batches >= 0) and (cur_batch >= args.num_batches):
             break
-        infer_results = inferer.infer(input=infer_data)
-
-        num_steps = len(infer_results) // len(infer_data)
+        infer_results = inferer.infer(input=infer_data,
+                                      feeding=data_generator.feeding)
+        start_pos = [0] * (len(infer_data) + 1)
+        for i in xrange(len(infer_data)):
+            start_pos[i + 1] = start_pos[i] + infer_data[i][3][0]
         probs_split = [
-            infer_results[i * num_steps:(i + 1) * num_steps]
-            for i in xrange(len(infer_data))
+                infer_results[start_pos[i]:start_pos[i + 1]]
+                for i in xrange(0, len(infer_data))
         ]
 
-        target_transcripts = [transcript for _, transcript in infer_data]
+        target_transcripts = [ data[1] for data in infer_data ]
 
         num_ins += len(target_transcripts)
         # grid search


Test patch:
Repository: PaddlePaddle/models

Issue:
Need to set the version of CTC decoders formally



Discussion:

Resolving patch:
diff --git a/deep_speech_2/decoders/swig/setup.py b/deep_speech_2/decoders/swig/setup.py
--- a/deep_speech_2/decoders/swig/setup.py
+++ b/deep_speech_2/decoders/swig/setup.py
@@ -70,7 +70,6 @@ def compile_test(header, library):
 
 FILES += glob.glob('openfst-1.6.3/src/lib/*.cc')
 
-# FILES + glob.glob('glog/src/*.cc')
 FILES = [
     fn for fn in FILES
     if not (fn.endswith('main.cc') or fn.endswith('test.cc') or fn.endswith(
@@ -107,7 +106,6 @@ def compile_test(header, library):
             'kenlm',
             'openfst-1.6.3/src/include',
             'ThreadPool',
-            #'glog/src'
         ],
         libraries=LIBS,
         extra_compile_args=ARGS)
@@ -115,7 +113,7 @@ def compile_test(header, library):
 
 setup(
     name='swig_decoders',
-    version='0.1',
+    version='1.0',
     description="""CTC decoders""",
     ext_modules=decoders_module,
     py_modules=['swig_decoders'], )


Test patch:
Repository: PaddlePaddle/models

Issue:
Bugs in ctr model.



Discussion:

Resolving patch:
diff --git a/ctr/avazu_data_processer.py b/ctr/avazu_data_processer.py
--- a/ctr/avazu_data_processer.py
+++ b/ctr/avazu_data_processer.py
@@ -2,6 +2,7 @@
 import csv
 import cPickle
 import argparse
+import os
 import numpy as np
 
 from utils import logger, TaskMode
diff --git a/ctr/network_conf.py b/ctr/network_conf.py
--- a/ctr/network_conf.py
+++ b/ctr/network_conf.py
@@ -50,7 +50,7 @@ def _declare_input_layers(self):
 
         self.lr_merged_input = layer.data(
             name='lr_input',
-            type=paddle.data_type.sparse_vector(self.lr_input_dim))
+            type=paddle.data_type.sparse_float_vector(self.lr_input_dim))
 
         if not self.is_infer:
             self.click = paddle.layer.data(


Test patch:
Repository: PaddlePaddle/models

Issue:
text_classification reader error
Get follow error log while running  `train.py`  of text_classification model:
```
[INFO 2017-11-16 17:19:51,458 train.py:44] please wait to build the word dictionary ...
[INFO 2017-11-16 17:20:07,138 train.py:101] length of word dictionary is : 5147.
I1116 17:20:07.168130 24638 Util.cpp:166] commandline:  --use_gpu=False --trainer_count=1
I1116 17:20:07.176143 24638 GradientMachine.cpp:94] Initing parameters..
I1116 17:20:07.186369 24638 GradientMachine.cpp:101] Init parameters done.
Traceback (most recent call last):
  File "train.py", line 178, in <module>
    main(args)
  File "train.py", line 169, in main
    model_save_dir=args.model_save_dir)
  File "train.py", line 150, in train
    num_passes=num_passes)
  File "/home/work/wanghaoshuang/paddle/python/install/lib/python2.7/site-packages/paddle/v2/trainer.py", line 162, in train
    for batch_id, data_batch in enumerate(reader()):
  File "/home/work/wanghaoshuang/paddle/python/install/lib/python2.7/site-packages/paddle/v2/minibatch.py", line 33, in batch_reader
    for instance in r:
  File "/home/work/wanghaoshuang/paddle/python/install/lib/python2.7/site-packages/paddle/v2/reader/decorator.py", line 67, in data_reader
    for e in reader():
TypeError: 'function' object is not iterable
```


Discussion:

Resolving patch:
diff --git a/text_classification/train.py b/text_classification/train.py
--- a/text_classification/train.py
+++ b/text_classification/train.py
@@ -46,10 +46,10 @@ def train(topology,
         word_dict = paddle.dataset.imdb.word_dict()
         train_reader = paddle.batch(
             paddle.reader.shuffle(
-                lambda: paddle.dataset.imdb.train(word_dict), buf_size=1000),
+                lambda: paddle.dataset.imdb.train(word_dict)(), buf_size=1000),
             batch_size=100)
         test_reader = paddle.batch(
-            lambda: paddle.dataset.imdb.test(word_dict), batch_size=100)
+            lambda: paddle.dataset.imdb.test(word_dict)(), batch_size=100)
 
         class_num = 2
     else:


Test patch:
Repository: PaddlePaddle/models

Issue:
Currently ci doesn't work properly 



Discussion:

Resolving patch:
diff --git a/conv_seq2seq/model.py b/conv_seq2seq/model.py
--- a/conv_seq2seq/model.py
+++ b/conv_seq2seq/model.py
@@ -147,7 +147,8 @@ def encoder(token_emb,
     encoded_sum = paddle.layer.addto(input=[encoded_vec, embedding])
 
     # halve the variance of the sum
-    encoded_sum = paddle.layer.slope_intercept(input=encoded_sum, slope=math.sqrt(0.5))
+    encoded_sum = paddle.layer.slope_intercept(
+        input=encoded_sum, slope=math.sqrt(0.5))
 
     return encoded_vec, encoded_sum
 


Test patch:
Repository: PaddlePaddle/models

Issue:
model/text_classification 使用内置语料集训练模型后，预测时出错，具体如下
```text
I1123 09:23:54.320137    84 Util.cpp:166] commandline:  --use_gpu=False --trainer_count=1 
Traceback (most recent call last):
  File "infer.py", line 91, in <module>
    batch_size=10)
  File "infer.py", line 58, in infer
    for idx, item in enumerate(test_reader):
TypeError: 'function' object is not iterable
```
paddle镜像用的是https://hub.docker.com/r/paddlepaddle/paddle/tags/ latest的，model下载的最新的


Discussion:
我来尝试复现一下该问题

Resolving patch:
diff --git a/text_classification/infer.py b/text_classification/infer.py
--- a/text_classification/infer.py
+++ b/text_classification/infer.py
@@ -28,7 +28,7 @@ def _infer_a_batch(inferer, test_batch, ids_2_word, ids_2_label):
         word_reverse_dict = dict((value, key)
                                  for key, value in word_dict.iteritems())
         label_reverse_dict = {0: "positive", 1: "negative"}
-        test_reader = paddle.dataset.imdb.test(word_dict)
+        test_reader = paddle.dataset.imdb.test(word_dict)()
     else:
         assert os.path.exists(
             word_dict_path), "the word dictionary file does not exist"


Test patch:
Repository: PaddlePaddle/models

Issue:
Bug fix for async reader of DeepASR



Discussion:

Resolving patch:
diff --git a/fluid/DeepASR/data_utils/async_data_reader.py b/fluid/DeepASR/data_utils/async_data_reader.py
--- a/fluid/DeepASR/data_utils/async_data_reader.py
+++ b/fluid/DeepASR/data_utils/async_data_reader.py
@@ -218,8 +218,6 @@ def __init__(self,
         self._sample_proc_num = self._proc_num - 2
         self._verbose = verbose
         self._force_exit = ForceExitWrapper(self._manager.Value('b', False))
-        self._pool_manager = SharedMemoryPoolManager(self._batch_buffer_size *
-                                                     3, self._manager)
 
     def generate_bucket_list(self, is_shuffle):
         if self._block_info_list is None:
@@ -424,6 +422,9 @@ def conv_to_shared(ndarray):
         sample_queue = self._start_async_processing()
         batch_queue = self._manager.Queue(self._batch_buffer_size)
 
+        self._pool_manager = SharedMemoryPoolManager(self._batch_buffer_size *
+                                                     3, self._manager)
+
         assembling_proc = DaemonProcessGroup(
             proc_num=1,
             target=batch_assembling_task,
@@ -439,3 +440,6 @@ def conv_to_shared(ndarray):
                 if isinstance(batch_data, EpochEndSignal):
                     break
                 yield batch_data
+
+        # clean the shared memory
+        del self._pool_manager
diff --git a/fluid/DeepASR/data_utils/util.py b/fluid/DeepASR/data_utils/util.py
--- a/fluid/DeepASR/data_utils/util.py
+++ b/fluid/DeepASR/data_utils/util.py
@@ -1,7 +1,7 @@
 from __future__ import absolute_import
 from __future__ import division
 from __future__ import print_function
-import sys
+import sys, time
 from six import reraise
 from tblib import Traceback
 from multiprocessing import Manager, Process
@@ -161,9 +161,10 @@ class is not process-safe, the pool can be shared between processes. All
     def __init__(self, pool_size, manager, name_prefix='/deep_asr'):
         self._names = []
         self._dict = manager.dict()
+        self._time_prefix = time.strftime('%Y%m%d%H%M%S')
 
         for i in xrange(pool_size):
-            name = name_prefix + '_' + str(i)
+            name = name_prefix + '_' + self._time_prefix + '_' + str(i)
             self._dict[name] = SharedNDArray(name)
             self._names.append(name)
 


Test patch:
Repository: PaddlePaddle/models

Issue:
Add decoder init & verify output



Discussion:

Resolving patch:
diff --git a/fluid/DeepASR/infer_by_ckpt.py b/fluid/DeepASR/infer_by_ckpt.py
--- a/fluid/DeepASR/infer_by_ckpt.py
+++ b/fluid/DeepASR/infer_by_ckpt.py
@@ -148,6 +148,10 @@ def infer_from_ckpt(args):
     # load checkpoint.
     fluid.io.load_persistables(exe, args.checkpoint)
 
+    # init decoder
+    decoder = Decoder(args.vocabulary, args.graphs, args.log_prior,
+                      args.acoustic_scale)
+
     ltrans = [
         trans_add_delta.TransAddDelta(2, 2),
         trans_mean_variance_norm.TransMeanVarianceNorm(args.mean_var),
@@ -184,7 +188,7 @@ def infer_from_ckpt(args):
         infer_batch = split_infer_result(probs, lod)
         for index, sample in enumerate(infer_batch):
             key = "utter#%d" % (batch_id * args.batch_size + index)
-            print(key, ": ", decoder.decode(key, sample), "\n")
+            print(key, ": ", decoder.decode(key, sample).encode("utf8"), "\n")
 
     print(np.mean(infer_costs), np.mean(infer_accs))
 


Test patch: