Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
Merge pull request #538 from weixing02/08
Browse files Browse the repository at this point in the history
fix 08.machine_translation/README.cn.md
  • Loading branch information
luotao1 authored Jun 8, 2018
2 parents f4b5cc8 + 5fcc8f7 commit 330cf3e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions 08.machine_translation/README.cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ $$e_{ij} = {align(z_i, h_j)}$$
# 加载 paddle的python包
import sys
import paddle.v2 as paddle
import numpy as np

# 配置只使用cpu,并且使用一个cpu进行训练
paddle.init(use_gpu=False, trainer_count=1)
Expand Down Expand Up @@ -273,11 +274,11 @@ is_generating = False
output_mem=decoder_mem,
size=decoder_size)
out = paddle.layer.mixed(
out = paddle.layer.fc(
size=target_dict_dim,
bias_attr=True,
act=paddle.activation.Softmax(),
input=paddle.layer.full_matrix_projection(input=gru_step))
input=gru_step)
return out
```
Expand Down Expand Up @@ -325,7 +326,7 @@ is_generating = False
6. 生成模式下的解码器调用:
- 首先,在序列生成任务中,由于解码阶段的RNN总是引用上一时刻生成出的词的词向量,作为当前时刻的输入,因此,使用`GeneratedInput`来自动完成这一过程。具体说明可见[GeneratedInput文档](https://github.com/PaddlePaddle/Paddle/blob/develop/doc/howto/deep_model/rnn/recurrent_group_cn.md#输入)。
- 首先,在序列生成任务中,由于解码阶段的RNN总是引用上一时刻生成出的词的词向量,作为当前时刻的输入,因此,使用`GeneratedInput`来自动完成这一过程。具体说明可见[GeneratedInput文档](https://github.com/PaddlePaddle/Paddle/blob/develop/doc/v2/howto/rnn/recurrent_group_cn.md#输入)。
- 其次,使用`beam_search`函数循环调用`gru_decoder_with_attention`函数,生成出序列id
```python
Expand Down
3 changes: 2 additions & 1 deletion 08.machine_translation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ This subset has 193319 instances of training data and 6003 instances of test dat
```python
import sys
import paddle.v2 as paddle
import numpy as np

# train with a single CPU
paddle.init(use_gpu=False, trainer_count=1)
Expand Down Expand Up @@ -326,7 +327,7 @@ is_generating = False
return out
```

4. Define the name for the decoder and the first two input for `gru_decoder_with_attention`. Note that `StaticInput` is used for the two inputs. Please refer to [StaticInput Document](https://github.com/PaddlePaddle/Paddle/blob/develop/doc/v2/howto/rnn/recurrent_group_en.md#input) for more details.
1. Define the name for the decoder and the first two input for `gru_decoder_with_attention`. Note that `StaticInput` is used for the two inputs. Please refer to [StaticInput Document](https://github.com/PaddlePaddle/Paddle/blob/develop/doc/v2/howto/rnn/recurrent_group_cn.md#input) for more details.

```python
decoder_group_name = "decoder_group"
Expand Down

0 comments on commit 330cf3e

Please sign in to comment.