diff --git a/04.word2vec/train.py b/04.word2vec/train.py index 3c28c8e6377d785a4e8d329866c2f253cdaa98fe..f296768324917ea9f7affaeea3c3b08683914a10 100644 --- a/04.word2vec/train.py +++ b/04.word2vec/train.py @@ -188,11 +188,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 = [[211L]] # 'among' - data2 = [[6L]] # 'a' - data3 = [[96L]] # 'group' - data4 = [[4L]] # 'of' - lod = [[1L]] + data1 = [[numpy.int64(211)]] # 'among' + data2 = [[numpy.int64(6)]] # 'a' + data3 = [[numpy.int64(96)]] # 'group' + data4 = [[numpy.int64(4)]] # 'of' + lod = [[numpy.int64(1)]] first_word = fluid.create_lod_tensor(data1, lod, place) second_word = fluid.create_lod_tensor(data2, lod, place) diff --git a/05.recommender_system/train.py b/05.recommender_system/train.py index 7b1f971b0a54f380345fc613d01ae5a24f9cc9eb..569cb0eccd42d3170d329cf01bfdb06611190f50 100644 --- a/05.recommender_system/train.py +++ b/05.recommender_system/train.py @@ -271,26 +271,28 @@ def infer(use_cuda, params_dirname): # Correspondingly, recursive_sequence_lengths = [[3, 2]] contains one # level of detail info, indicating that `data` consists of two sequences # of length 3 and 2, respectively. - user_id = fluid.create_lod_tensor([[1L]], [[1]], place) + user_id = fluid.create_lod_tensor([[np.int64(1)]], [[1]], place) assert feed_target_names[1] == "gender_id" - gender_id = fluid.create_lod_tensor([[1L]], [[1]], place) + gender_id = fluid.create_lod_tensor([[np.int64(1)]], [[1]], place) assert feed_target_names[2] == "age_id" - age_id = fluid.create_lod_tensor([[0L]], [[1]], place) + age_id = fluid.create_lod_tensor([[np.int64(0)]], [[1]], place) assert feed_target_names[3] == "job_id" - job_id = fluid.create_lod_tensor([[10L]], [[1]], place) + job_id = fluid.create_lod_tensor([[np.int64(10)]], [[1]], place) assert feed_target_names[4] == "movie_id" - movie_id = fluid.create_lod_tensor([[783L]], [[1]], place) + movie_id = fluid.create_lod_tensor([[np.int64(783)]], [[1]], place) assert feed_target_names[5] == "category_id" - category_id = fluid.create_lod_tensor([[10L, 8L, 9L]], [[3]], place) + category_id = fluid.create_lod_tensor( + [np.array([10, 8, 9], dtype='int64')], [[3]], place) assert feed_target_names[6] == "movie_title" movie_title = fluid.create_lod_tensor( - [[1069L, 4140L, 2923L, 710L, 988L]], [[5]], place) + [np.array([1069, 4140, 2923, 710, 988], dtype='int64')], [[5]], + place) # Construct feed as a dictionary of {feed_target_name: feed_target_data} # and results will contain a list of data corresponding to fetch_targets.