提交 f3bc752a 编写于 作者: Y Youwei Song 提交者: lujun

use numpy.asarray as data initializer (#769)

use numpy.asarray as data initializer
上级 25cab9f5
......@@ -444,11 +444,11 @@ def infer(use_cuda, params_dirname=None):
# 用来查询embedding表获取对应的词向量,因此其形状大小是[1]。
# recursive_sequence_lengths设置的是基于长度的LoD,因此都应该设为[[1]]
# 注意recursive_sequence_lengths是列表的列表
data1 = [[211]] # 'among'
data2 = [[6]] # 'a'
data3 = [[96]] # 'group'
data4 = [[4]] # 'of'
lod = [[1]]
data1 = numpy.asarray([[211]], dtype=numpy.int64) # 'among'
data2 = numpy.asarray([[6]], dtype=numpy.int64) # 'a'
data3 = numpy.asarray([[96]], dtype=numpy.int64) # 'group'
data4 = numpy.asarray([[4]], dtype=numpy.int64) # 'of'
lod = numpy.asarray([[1]], dtype=numpy.int64)
first_word = fluid.create_lod_tensor(data1, lod, place)
second_word = fluid.create_lod_tensor(data2, lod, place)
......
......@@ -409,11 +409,11 @@ def infer(use_cuda, params_dirname=None):
# Used to query the embedding table to get the corresponding word vector, so its shape size is [1].
# recursive_sequence_lengths sets the length based on LoD, so it should all be set to [[1]]
# Note that recursive_sequence_lengths is a list of lists
data1 = [[211]] # 'among'
data2 = [[6]] # 'a'
data3 = [[96]] # 'group'
data4 = [[4]] # 'of'
lod = [[1]]
data1 = numpy.asarray([[211]], dtype=numpy.int64) # 'among'
data2 = numpy.asarray([[6]], dtype=numpy.int64) # 'a'
data3 = numpy.asarray([[96]], dtype=numpy.int64) # 'group'
data4 = numpy.asarray([[4]], dtype=numpy.int64) # 'of'
lod = numpy.asarray([[1]], dtype=numpy.int64)
first_word = fluid.create_lod_tensor(data1, lod, place)
second_word = fluid.create_lod_tensor(data2, lod, place)
......
......@@ -486,11 +486,11 @@ def infer(use_cuda, params_dirname=None):
# 用来查询embedding表获取对应的词向量,因此其形状大小是[1]。
# recursive_sequence_lengths设置的是基于长度的LoD,因此都应该设为[[1]]
# 注意recursive_sequence_lengths是列表的列表
data1 = [[211]] # 'among'
data2 = [[6]] # 'a'
data3 = [[96]] # 'group'
data4 = [[4]] # 'of'
lod = [[1]]
data1 = numpy.asarray([[211]], dtype=numpy.int64) # 'among'
data2 = numpy.asarray([[6]], dtype=numpy.int64) # 'a'
data3 = numpy.asarray([[96]], dtype=numpy.int64) # 'group'
data4 = numpy.asarray([[4]], dtype=numpy.int64) # 'of'
lod = numpy.asarray([[1]], dtype=numpy.int64)
first_word = fluid.create_lod_tensor(data1, lod, place)
second_word = fluid.create_lod_tensor(data2, lod, place)
......
......@@ -451,11 +451,11 @@ def infer(use_cuda, params_dirname=None):
# Used to query the embedding table to get the corresponding word vector, so its shape size is [1].
# recursive_sequence_lengths sets the length based on LoD, so it should all be set to [[1]]
# Note that recursive_sequence_lengths is a list of lists
data1 = [[211]] # 'among'
data2 = [[6]] # 'a'
data3 = [[96]] # 'group'
data4 = [[4]] # 'of'
lod = [[1]]
data1 = numpy.asarray([[211]], dtype=numpy.int64) # 'among'
data2 = numpy.asarray([[6]], dtype=numpy.int64) # 'a'
data3 = numpy.asarray([[96]], dtype=numpy.int64) # 'group'
data4 = numpy.asarray([[4]], dtype=numpy.int64) # 'of'
lod = numpy.asarray([[1]], dtype=numpy.int64)
first_word = fluid.create_lod_tensor(data1, lod, place)
second_word = fluid.create_lod_tensor(data2, lod, place)
......
......@@ -206,11 +206,11 @@ def infer(use_cuda, params_dirname=None):
# meaning there is only one level of detail and there is only one sequence of
# one word on this level.
# Note that recursive_sequence_lengths should be a list of lists.
data1 = [[numpy.int64(211)]] # 'among'
data2 = [[numpy.int64(6)]] # 'a'
data3 = [[numpy.int64(96)]] # 'group'
data4 = [[numpy.int64(4)]] # 'of'
lod = [[numpy.int64(1)]]
data1 = numpy.asarray([[211]], dtype=numpy.int64) # 'among'
data2 = numpy.asarray([[6]], dtype=numpy.int64) # 'a'
data3 = numpy.asarray([[96]], dtype=numpy.int64) # 'group'
data4 = numpy.asarray([[4]], dtype=numpy.int64) # 'of'
lod = numpy.asarray([[1]], dtype=numpy.int64)
first_word = fluid.create_lod_tensor(data1, lod, place)
second_word = fluid.create_lod_tensor(data2, lod, place)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册