diff --git a/04.word2vec/README.md b/04.word2vec/README.md index 352d3adf42de486d10afb389c5b4cda9f4e74977..a859d4845f7f6483f7e51c6ce24579bff6a7f994 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 c97cb748e3757045bc38158f607c5ad06671aee3..e907896843600f729b761b49f5c74ecd52a2fa8b 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 d84440ff2e4f922e3681ca346029a36de93dc594..4c804c4f1231e324cfa20ed414880488d1c891d9 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 151ffb607c4f0c322369cbb3ee3c0c842352af42..16906208e6e9426e74344e06ce444d5eb5c89445 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.