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

Rewrite book chapter8 machine translation documentation and train.py #552

Conversation

nickyfantasy
Copy link
Contributor

No description provided.

Copy link
Contributor

@daming-lu daming-lu left a 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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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.
Copy link
Contributor

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')
Copy link
Contributor

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
Copy link
Contributor

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

@daming-lu daming-lu merged commit af0ec47 into PaddlePaddle:high-level-api-branch Jun 22, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants