-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Rewrite book chapter8 machine translation documentation and train.py #552
Rewrite book chapter8 machine translation documentation and train.py #552
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need some fixes
from functools import partial | ||
import os | ||
|
||
dict_size = 30000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the old comments here : # dict dim
bias_attr=False, | ||
input=backward_first) | ||
def encoder(is_sparse): | ||
# encoder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we do not need this comment
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. | ||
```python | ||
def train_decoder(context, is_sparse): | ||
# decoder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nor this comment
|
||
Print sequence and its `beam_size` generated translation results based on the dictionary. | ||
We initialize ids and scores and create tensors for input. This test we are using first record data from `wmt14.test` for inference. At the end we get src dict and target dict for printing out results later. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this test, we are using the first record data ...
```python | ||
init_ids_data = np.array([1 for _ in range(batch_size)], dtype='int64') | ||
init_scores_data = np.array( | ||
[1. for _ in range(batch_size)], dtype='float32') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
they could simply do this [1.0] * batch_size
from functools import partial | ||
import os | ||
|
||
dict_size = 30000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add the old comments here
No description provided.