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 0ddf0365651b4fb6ae14ceab02afb18263971f7d..e1904dfa0890e80a48b41195ebd8adf931d460bd 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 fa80ac7d8a5500fe4781b0e79e30ae4a2745a6ae..12aadc03a97a0b60bf46f21d527bbefd80c7227b 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 29ff80587b6ef8cbc8504ef30282fc286557938f..19fe031db4707ab8a89268b51d8848644a57cc95 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 679cdd76545f63cdb5bad135434e6e7a35014681..865141cc8f42537de9e5f1e957ac3e99ab339472 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"