提交 6274cc99 编写于 作者: K ktlichkid 提交者: Qingsheng Li

Modified model for python 3

上级 995627c5
...@@ -18,6 +18,7 @@ from __future__ import print_function ...@@ -18,6 +18,7 @@ from __future__ import print_function
import numpy as np import numpy as np
import os import os
import six
import paddle import paddle
import paddle.fluid as fluid import paddle.fluid as fluid
...@@ -102,7 +103,7 @@ def infer(): ...@@ -102,7 +103,7 @@ def infer():
init_recursive_seq_lens, place) init_recursive_seq_lens, place)
# Feed dict for inference # Feed dict for inference
feed_dict = feeder.feed(map(lambda x: [x[0]], data)) feed_dict = feeder.feed([[x[0]] for x in data])
feed_dict['init_ids'] = init_ids feed_dict['init_ids'] = init_ids
feed_dict['init_scores'] = init_scores feed_dict['init_scores'] = init_scores
...@@ -115,7 +116,7 @@ def infer(): ...@@ -115,7 +116,7 @@ def infer():
lod_level_1 = fetch_outs[0].lod()[1] lod_level_1 = fetch_outs[0].lod()[1]
token_array = np.array(fetch_outs[0]) token_array = np.array(fetch_outs[0])
result = [] result = []
for i in xrange(len(lod_level_1) - 1): for i in six.moves.xrange(len(lod_level_1) - 1):
sentence_list = [ sentence_list = [
trg_dict[token] trg_dict[token]
for token in token_array[lod_level_1[i]:lod_level_1[i + 1]] for token in token_array[lod_level_1[i]:lod_level_1[i + 1]]
...@@ -125,7 +126,7 @@ def infer(): ...@@ -125,7 +126,7 @@ def infer():
lod_level_0 = fetch_outs[0].lod()[0] lod_level_0 = fetch_outs[0].lod()[0]
paragraphs = [ paragraphs = [
result[lod_level_0[i]:lod_level_0[i + 1]] result[lod_level_0[i]:lod_level_0[i + 1]]
for i in xrange(len(lod_level_0) - 1) for i in six.moves.xrange(len(lod_level_0) - 1)
] ]
for paragraph in paragraphs: for paragraph in paragraphs:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册