From b5d917eb280710bc9135d5f69e5931a81bcc49e4 Mon Sep 17 00:00:00 2001 From: Li Fuchen Date: Wed, 23 Oct 2019 13:47:15 +0800 Subject: [PATCH] fix bugs in Readme.md of 04 and 07 (#831) --- 04.word2vec/README.md | 16 ++++++++-------- 04.word2vec/index.html | 16 ++++++++-------- 07.label_semantic_roles/README.md | 12 ++++++------ 07.label_semantic_roles/index.html | 12 ++++++------ 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/04.word2vec/README.md b/04.word2vec/README.md index 352d3ad..a859d48 100644 --- a/04.word2vec/README.md +++ b/04.word2vec/README.md @@ -203,7 +203,7 @@ First, load packages: from __future__ import print_function -import paddle as paddle +import paddle import paddle.fluid as fluid import six import numpy @@ -214,13 +214,13 @@ import math Then, define the parameters: ```python -EMBED_SIZE = 32 # embedding dimensions +EMBED_SIZE = 32 # embedding dimensions HIDDEN_SIZE = 256 # hidden layer size -N = 5 # ngram size, here fixed 5 -BATCH_SIZE = 100 # batch size -PASS_NUM = 100 # Training rounds +N = 5 # ngram size, here fixed 5 +BATCH_SIZE = 100 # batch size +PASS_NUM = 100 # Training rounds -use_cuda = False # Set to True if trained with GPU +use_cuda = False # Set to True if trained with GPU word_dict = paddle.dataset.imikolov.build_dict() dict_size = len(word_dict) @@ -337,7 +337,7 @@ def train(if_use_cuda, params_dirname, is_sparse=True): accumulated = [ x[0] + x[1][0] for x in zip(accumulated, avg_cost_np) ] - count += 1 + count += 1 return [x / count for x in accumulated] def train_loop(): @@ -403,7 +403,7 @@ def infer(use_cuda, params_dirname=None): #Get the inference program using fluid.io.load_inference_model, #feed variable name by feed_target_names and fetch fetch_targets from scope [inferencer, feed_target_names, - fetch_targets] = fluid.io.load_inference_model(params_dirname, exe) + fetch_targets] = fluid.io.load_inference_model(params_dirname, exe) # Set the input and use 4 LoDTensor to represent 4 words. Each word here is an id, # Used to query the embedding table to get the corresponding word vector, so its shape size is [1]. diff --git a/04.word2vec/index.html b/04.word2vec/index.html index c97cb74..e907896 100644 --- a/04.word2vec/index.html +++ b/04.word2vec/index.html @@ -245,7 +245,7 @@ First, load packages: from __future__ import print_function -import paddle as paddle +import paddle import paddle.fluid as fluid import six import numpy @@ -256,13 +256,13 @@ import math Then, define the parameters: ```python -EMBED_SIZE = 32 # embedding dimensions +EMBED_SIZE = 32 # embedding dimensions HIDDEN_SIZE = 256 # hidden layer size -N = 5 # ngram size, here fixed 5 -BATCH_SIZE = 100 # batch size -PASS_NUM = 100 # Training rounds +N = 5 # ngram size, here fixed 5 +BATCH_SIZE = 100 # batch size +PASS_NUM = 100 # Training rounds -use_cuda = False # Set to True if trained with GPU +use_cuda = False # Set to True if trained with GPU word_dict = paddle.dataset.imikolov.build_dict() dict_size = len(word_dict) @@ -379,7 +379,7 @@ def train(if_use_cuda, params_dirname, is_sparse=True): accumulated = [ x[0] + x[1][0] for x in zip(accumulated, avg_cost_np) ] - count += 1 + count += 1 return [x / count for x in accumulated] def train_loop(): @@ -445,7 +445,7 @@ def infer(use_cuda, params_dirname=None): #Get the inference program using fluid.io.load_inference_model, #feed variable name by feed_target_names and fetch fetch_targets from scope [inferencer, feed_target_names, - fetch_targets] = fluid.io.load_inference_model(params_dirname, exe) + fetch_targets] = fluid.io.load_inference_model(params_dirname, exe) # Set the input and use 4 LoDTensor to represent 4 words. Each word here is an id, # Used to query the embedding table to get the corresponding word vector, so its shape size is [1]. diff --git a/07.label_semantic_roles/README.md b/07.label_semantic_roles/README.md index d84440f..4c804c4 100644 --- a/07.label_semantic_roles/README.md +++ b/07.label_semantic_roles/README.md @@ -208,17 +208,17 @@ print('pred_dict_len: ', pred_dict_len) ```python mark_dict_len = 2 # The dimension of the context area flag, which is a 0-1 2 value feature, so the dimension is 2 -Word_dim = 32 # Word vector dimension -Mark_dim = 5 # The predicate context area is mapped to a real vector by the vocabulary, which is the adjacent dimension -Hidden_dim = 512 # LSTM Hidden Layer Vector Dimensions : 512 / 4 -Depth = 8 # depth of stack LSTM -Mix_hidden_lr = 1e-3 # Basic learning rate of fundamental_chain_crf layer +word_dim = 32 # Word vector dimension +mark_dim = 5 # The predicate context area is mapped to a real vector by the vocabulary, which is the adjacent dimension +hidden_dim = 512 # LSTM Hidden Layer Vector Dimensions : 512 / 4 +depth = 8 # depth of stack LSTM +mix_hidden_lr = 1e-3 # Basic learning rate of fundamental_chain_crf layer IS_SPARSE = True # Whether to update embedding in sparse way PASS_NUM = 10 # Training epoches BATCH_SIZE = 10 # Batch size -Embeddding_name = 'emb' +embedding_name = 'emb' ``` It should be specially noted that the parameter `hidden_dim = 512` actually specifies the dimension of the LSTM hidden layer's vector is 128. For this, please refer to the description of `dynamic_lstm` in the official PaddlePaddle API documentation. diff --git a/07.label_semantic_roles/index.html b/07.label_semantic_roles/index.html index 151ffb6..1690620 100644 --- a/07.label_semantic_roles/index.html +++ b/07.label_semantic_roles/index.html @@ -250,17 +250,17 @@ print('pred_dict_len: ', pred_dict_len) ```python mark_dict_len = 2 # The dimension of the context area flag, which is a 0-1 2 value feature, so the dimension is 2 -Word_dim = 32 # Word vector dimension -Mark_dim = 5 # The predicate context area is mapped to a real vector by the vocabulary, which is the adjacent dimension -Hidden_dim = 512 # LSTM Hidden Layer Vector Dimensions : 512 / 4 -Depth = 8 # depth of stack LSTM -Mix_hidden_lr = 1e-3 # Basic learning rate of fundamental_chain_crf layer +word_dim = 32 # Word vector dimension +mark_dim = 5 # The predicate context area is mapped to a real vector by the vocabulary, which is the adjacent dimension +hidden_dim = 512 # LSTM Hidden Layer Vector Dimensions : 512 / 4 +depth = 8 # depth of stack LSTM +mix_hidden_lr = 1e-3 # Basic learning rate of fundamental_chain_crf layer IS_SPARSE = True # Whether to update embedding in sparse way PASS_NUM = 10 # Training epoches BATCH_SIZE = 10 # Batch size -Embeddding_name = 'emb' +embedding_name = 'emb' ``` It should be specially noted that the parameter `hidden_dim = 512` actually specifies the dimension of the LSTM hidden layer's vector is 128. For this, please refer to the description of `dynamic_lstm` in the official PaddlePaddle API documentation. -- GitLab