diff --git a/doc/fluid/user_guides/nlp_case/understand_sentiment/README.cn.md b/doc/fluid/user_guides/nlp_case/understand_sentiment/README.cn.md index ce9cd776d6d4b726065f511abf720757764e8fe2..199e18ed8854138e962327e9734021ab56807deb 100644 --- a/doc/fluid/user_guides/nlp_case/understand_sentiment/README.cn.md +++ b/doc/fluid/user_guides/nlp_case/understand_sentiment/README.cn.md @@ -394,7 +394,7 @@ inference_scope = fluid.core.Scope() ```python reviews_str = [ - 'read the book forget the movie', 'this is a great movie', 'this is very bad' + b'read the book forget the movie', b'this is a great movie', b'this is very bad' ] reviews = [c.split() for c in reviews_str] @@ -404,6 +404,7 @@ for c in reviews: lod.append([word_dict.get(words, UNK) for words in c]) base_shape = [[len(c) for c in lod]] +lod = np.array(sum(lod, []), dtype=np.int64) tensor_words = fluid.create_lod_tensor(lod, base_shape, place) ``` diff --git a/doc/fluid/user_guides/nlp_case/understand_sentiment/README.md b/doc/fluid/user_guides/nlp_case/understand_sentiment/README.md index 5e18077cec00eae50663f4523841dfbb6eeb9aca..00ed9efb77e0d45bc15c212d1d6a67a06aebf07f 100644 --- a/doc/fluid/user_guides/nlp_case/understand_sentiment/README.md +++ b/doc/fluid/user_guides/nlp_case/understand_sentiment/README.md @@ -383,7 +383,7 @@ Then we use `create_lod_tensor` to create the tensor of the detail level. For a ```python reviews_str = [ - 'read the book forget the movie', 'this is a great movie', 'this is very bad' + b'read the book forget the movie', b'this is a great movie', b'this is very bad' ] reviews = [c.split() for c in reviews_str] @@ -393,6 +393,7 @@ for c in reviews: lod.append([word_dict.get(words, UNK) for words in c]) base_shape = [[len(c) for c in lod]] +lod = np.array(sum(lod, []), dtype=np.int64) tensor_words = fluid.create_lod_tensor(lod, base_shape, place) ``` diff --git a/doc/fluid/user_guides/nlp_case/understand_sentiment/index.cn.html b/doc/fluid/user_guides/nlp_case/understand_sentiment/index.cn.html index 4af2290740ecebcdedff52a383408aa50e13fdf0..a1d945d359e945f60d16bb135c6e47cf24a555d5 100644 --- a/doc/fluid/user_guides/nlp_case/understand_sentiment/index.cn.html +++ b/doc/fluid/user_guides/nlp_case/understand_sentiment/index.cn.html @@ -436,7 +436,7 @@ inference_scope = fluid.core.Scope() ```python reviews_str = [ - 'read the book forget the movie', 'this is a great movie', 'this is very bad' + b'read the book forget the movie', b'this is a great movie', b'this is very bad' ] reviews = [c.split() for c in reviews_str] @@ -446,6 +446,7 @@ for c in reviews: lod.append([word_dict.get(words, UNK) for words in c]) base_shape = [[len(c) for c in lod]] +lod = np.array(sum(lod, []), dtype=np.int64) tensor_words = fluid.create_lod_tensor(lod, base_shape, place) ``` diff --git a/doc/fluid/user_guides/nlp_case/understand_sentiment/index.html b/doc/fluid/user_guides/nlp_case/understand_sentiment/index.html index 45604f13c72ae2a40f6b5f971ea27ee2f65f1048..ecd861f300028e4deacb742dbaffffef3c947556 100644 --- a/doc/fluid/user_guides/nlp_case/understand_sentiment/index.html +++ b/doc/fluid/user_guides/nlp_case/understand_sentiment/index.html @@ -425,7 +425,7 @@ Then we use `create_lod_tensor` to create the tensor of the detail level. For a ```python reviews_str = [ - 'read the book forget the movie', 'this is a great movie', 'this is very bad' + b'read the book forget the movie', b'this is a great movie', b'this is very bad' ] reviews = [c.split() for c in reviews_str] @@ -435,6 +435,7 @@ for c in reviews: lod.append([word_dict.get(words, UNK) for words in c]) base_shape = [[len(c) for c in lod]] +lod = np.array(sum(lod, []), dtype=np.int64) tensor_words = fluid.create_lod_tensor(lod, base_shape, place) ``` diff --git a/doc/fluid/user_guides/nlp_case/understand_sentiment/train_conv.py b/doc/fluid/user_guides/nlp_case/understand_sentiment/train_conv.py index 74547461500e5532e44208ef2d589984a20320e8..456b127b92c6814fa44e7bc579e6e2f95110cb33 100644 --- a/doc/fluid/user_guides/nlp_case/understand_sentiment/train_conv.py +++ b/doc/fluid/user_guides/nlp_case/understand_sentiment/train_conv.py @@ -205,8 +205,8 @@ def infer(use_cuda, params_dirname=None): # length 3, 4 and 2, respectively. # Note that lod info should be a list of lists. reviews_str = [ - 'read the book forget the movie', 'this is a great movie', - 'this is very bad' + b'read the book forget the movie', b'this is a great movie', + b'this is very bad' ] reviews = [c.split() for c in reviews_str] @@ -216,6 +216,7 @@ def infer(use_cuda, params_dirname=None): lod.append([np.int64(word_dict.get(words, UNK)) for words in c]) base_shape = [[len(c) for c in lod]] + lod = np.array(sum(lod, []), dtype=np.int64) tensor_words = fluid.create_lod_tensor(lod, base_shape, place) assert feed_target_names[0] == "words" diff --git a/doc/fluid/user_guides/nlp_case/understand_sentiment/train_dyn_rnn.py b/doc/fluid/user_guides/nlp_case/understand_sentiment/train_dyn_rnn.py index 78f3d64b43dc50efe195615016d5e92f2d40e9e5..b782f6435a68c0f01fae9e03568a8dc9946bee70 100644 --- a/doc/fluid/user_guides/nlp_case/understand_sentiment/train_dyn_rnn.py +++ b/doc/fluid/user_guides/nlp_case/understand_sentiment/train_dyn_rnn.py @@ -194,8 +194,8 @@ def infer(use_cuda, params_dirname=None): # length 3, 4 and 2, respectively. # Note that lod info should be a list of lists. reviews_str = [ - 'read the book forget the movie', 'this is a great movie', - 'this is very bad' + b'read the book forget the movie', b'this is a great movie', + b'this is very bad' ] reviews = [c.split() for c in reviews_str] @@ -205,6 +205,7 @@ def infer(use_cuda, params_dirname=None): lod.append([np.int64(word_dict.get(words, UNK)) for words in c]) base_shape = [[len(c) for c in lod]] + lod = np.array(sum(lod, []), dtype=np.int64) tensor_words = fluid.create_lod_tensor(lod, base_shape, place) assert feed_target_names[0] == "words" diff --git a/doc/fluid/user_guides/nlp_case/understand_sentiment/train_stacked_lstm.py b/doc/fluid/user_guides/nlp_case/understand_sentiment/train_stacked_lstm.py index 5878c7f738557e756e816b78d24af0c16b2b48bd..6db40f42a3fbda12c764d76151db21a1c3e4df04 100644 --- a/doc/fluid/user_guides/nlp_case/understand_sentiment/train_stacked_lstm.py +++ b/doc/fluid/user_guides/nlp_case/understand_sentiment/train_stacked_lstm.py @@ -216,8 +216,8 @@ def infer(use_cuda, params_dirname=None): # length 3, 4 and 2, respectively. # Note that lod info should be a list of lists. reviews_str = [ - 'read the book forget the movie', 'this is a great movie', - 'this is very bad' + b'read the book forget the movie', b'this is a great movie', + b'this is very bad' ] reviews = [c.split() for c in reviews_str] @@ -227,6 +227,7 @@ def infer(use_cuda, params_dirname=None): lod.append([np.int64(word_dict.get(words, UNK)) for words in c]) base_shape = [[len(c) for c in lod]] + lod = np.array(sum(lod, []), dtype=np.int64) tensor_words = fluid.create_lod_tensor(lod, base_shape, place) assert feed_target_names[0] == "words"