diff --git a/04.word2vec/README.cn.md b/04.word2vec/README.cn.md index d43a118fa701f4b29f13b173b542d00e0a3d982d..bf5d51bec9c1c5d4df82830c7e57fc7710ddbcb7 100644 --- a/04.word2vec/README.cn.md +++ b/04.word2vec/README.cn.md @@ -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) diff --git a/04.word2vec/README.md b/04.word2vec/README.md index 2002e4798aa3069fc60964a8d743f1deb4dc7632..eb3e44a3cab784372227a17cd99c890f2adf1f3b 100644 --- a/04.word2vec/README.md +++ b/04.word2vec/README.md @@ -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) diff --git a/04.word2vec/index.cn.html b/04.word2vec/index.cn.html index b7b727cebb6150c529bee3869488268b7f85fc97..73cbd2ee29d2c243a9dfe1c69930878f54ecb6c6 100644 --- a/04.word2vec/index.cn.html +++ b/04.word2vec/index.cn.html @@ -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) diff --git a/04.word2vec/index.html b/04.word2vec/index.html index f67aeba9d25328734006374787e7898ebdadaa48..ab5e1f68d43cf154d19e24361e7cf0f73fc5914d 100644 --- a/04.word2vec/index.html +++ b/04.word2vec/index.html @@ -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) diff --git a/04.word2vec/train.py b/04.word2vec/train.py index eebf62234ff408e24159e6bf6895ca5f85ef1a2d..2b3a97276d8fbd35b78ec480f2d1ea4496e0f62a 100644 --- a/04.word2vec/train.py +++ b/04.word2vec/train.py @@ -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)