diff --git a/06.label_semantic_roles/README.en.md b/06.label_semantic_roles/README.en.md index f18464fae77b9ca0affb74b3ba1585af079cd578..079b9613a9f8931b465be2af69b04d3b741eade1 100644 --- a/06.label_semantic_roles/README.en.md +++ b/06.label_semantic_roles/README.en.md @@ -346,10 +346,10 @@ for i in range(1, depth): - In PaddlePaddle, state features and transition features of a CRF are implemented by a fully connected layer and a CRF layer seperately. The fully connected layer with linear activation learns the state features, here we use paddle.layer.mixed (paddle.layer.fc can be uesed as well), and the CRF layer in PaddlePaddle: paddle.layer.crf only learns the transition features, which is a cost layer and is the last layer of the network. paddle.layer.crf outputs the log probability of true tag sequence as the cost by given the input sequence and it requires the true tag sequence as target in the learning process. ```python -# the fully connected layer learns the state features -# The output of the top LSTM unit and its input are concatenated -# and then is feed into a fully connected layer, + +# The output of the top LSTM unit and its input are feed into a fully connected layer, # size of which equals to size of tag labels. +# The fully connected layer learns the state features feature_out = paddle.layer.mixed( size=label_dict_len, @@ -370,7 +370,7 @@ crf_cost = paddle.layer.crf( learning_rate=mix_hidden_lr)) ``` -- The CRF decoding layer is used for evaluation and inference. It shares weights with CRF layer. The sharing of parameters among multiple layers is specified by using the same parameter name in these layers. +- The CRF decoding layer is used for evaluation and inference. It shares weights with CRF layer. The sharing of parameters among multiple layers is specified by using the same parameter name in these layers. If true tag sequence is provided in training process, `paddle.layer.crf_decoding` calculates labelling error for each input token and `evaluator.sum` sum the error over the entire sequence. Otherwise, `paddle.layer.crf_decoding` generates the labelling tags. ```python crf_dec = paddle.layer.crf_decoding( diff --git a/06.label_semantic_roles/README.md b/06.label_semantic_roles/README.md index 3f1c243c52295dd7edb80896f737c565c978a4c3..a0e8b42622983fdf8070184048ba84dfb3d177b6 100644 --- a/06.label_semantic_roles/README.md +++ b/06.label_semantic_roles/README.md @@ -324,7 +324,9 @@ for i in range(1, depth): ```python -# 学习 CRF 的状态特征 +# 取最后一个栈式LSTM的输出和这个LSTM单元的输入到隐层映射, +# 经过一个全连接层映射到标记字典的维度,来学习 CRF 的状态特征 + feature_out = paddle.layer.mixed( size=label_dict_len, bias_attr=std_default, diff --git a/06.label_semantic_roles/index.en.html b/06.label_semantic_roles/index.en.html index e5eef7d2a5e5ac785c27f7d4b9559c7db8436474..5cd490d4ca5b56fee8ef4762fdc0a62a09724b6c 100644 --- a/06.label_semantic_roles/index.en.html +++ b/06.label_semantic_roles/index.en.html @@ -388,10 +388,10 @@ for i in range(1, depth): - In PaddlePaddle, state features and transition features of a CRF are implemented by a fully connected layer and a CRF layer seperately. The fully connected layer with linear activation learns the state features, here we use paddle.layer.mixed (paddle.layer.fc can be uesed as well), and the CRF layer in PaddlePaddle: paddle.layer.crf only learns the transition features, which is a cost layer and is the last layer of the network. paddle.layer.crf outputs the log probability of true tag sequence as the cost by given the input sequence and it requires the true tag sequence as target in the learning process. ```python -# the fully connected layer learns the state features -# The output of the top LSTM unit and its input are concatenated -# and then is feed into a fully connected layer, + +# The output of the top LSTM unit and its input are feed into a fully connected layer, # size of which equals to size of tag labels. +# The fully connected layer learns the state features feature_out = paddle.layer.mixed( size=label_dict_len, @@ -412,7 +412,7 @@ crf_cost = paddle.layer.crf( learning_rate=mix_hidden_lr)) ``` -- The CRF decoding layer is used for evaluation and inference. It shares weights with CRF layer. The sharing of parameters among multiple layers is specified by using the same parameter name in these layers. +- The CRF decoding layer is used for evaluation and inference. It shares weights with CRF layer. The sharing of parameters among multiple layers is specified by using the same parameter name in these layers. If true tag sequence is provided in training process, `paddle.layer.crf_decoding` calculates labelling error for each input token and `evaluator.sum` sum the error over the entire sequence. Otherwise, `paddle.layer.crf_decoding` generates the labelling tags. ```python crf_dec = paddle.layer.crf_decoding( diff --git a/06.label_semantic_roles/index.html b/06.label_semantic_roles/index.html index 082e4ca36e61d52eb44eb8c40c865f2c55b159a8..5f78688f00e27b3f40639c390cf42f12d101960c 100644 --- a/06.label_semantic_roles/index.html +++ b/06.label_semantic_roles/index.html @@ -366,7 +366,9 @@ for i in range(1, depth): ```python -# 学习 CRF 的状态特征 +# 取最后一个栈式LSTM的输出和这个LSTM单元的输入到隐层映射, +# 经过一个全连接层映射到标记字典的维度,来学习 CRF 的状态特征 + feature_out = paddle.layer.mixed( size=label_dict_len, bias_attr=std_default,