Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the model in test_machine_translation.py. #7770

Merged
merged 2 commits into from
Jan 25, 2018

Conversation

peterzhang2029
Copy link
Contributor

resolve #7012

size=hidden_size * 4,
act='tanh',
bias_attr=True)
reversed, _ = fluid.layers.dynamic_lstm(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reversed -->backward.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

size=hidden_size * 4,
is_reverse=True,
use_peepholes=USE_PEEPHOLES)
return forward, reversed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reversed -->backward.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

def bi_lstm_encoder(input_seq, hidden_size):
input_forward_proj = fluid.layers.fc(input=input_seq,
size=hidden_size * 4,
act='tanh',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的fc 是下图红色计算,为什么要加 tanh 呢?
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已去掉'tanh'

use_peepholes=USE_PEEPHOLES)
input_reversed_proj = fluid.layers.fc(input=input_seq,
size=hidden_size * 4,
act='tanh',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上,为什么要使用“tanh”激活?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已去掉'tanh'



def lstm_step(x_t, hidden_t_prev, cell_t_prev, size):
def linear(inputs):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

加一个 fixme 的comment, replace this function with the lstm_unit_op.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

encoded_vector = fluid.layers.concat(
input=[src_forward, src_reversed], axis=1)

context = fluid.layers.sequence_pool(input=encoded_vector, pool_type='last')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请确认一下现在op的逻辑,reverse的时候是否要取first 而不是last。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已确认,reverse时也是取last。

Copy link
Contributor

@lcy-seso lcy-seso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lcy-seso lcy-seso merged commit f91f134 into PaddlePaddle:develop Jan 25, 2018
@peterzhang2029 peterzhang2029 deleted the nmt_fix branch January 25, 2018 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The model in test_machine_translation.py is not correct.
3 participants