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

[API 2.0] Add transformer apis #26418

Merged
merged 22 commits into from
Aug 24, 2020

Conversation

guoshengCS
Copy link
Contributor

@guoshengCS guoshengCS commented Aug 18, 2020

PR types

New features

PR changes

APIs

Describe

Add transformer apis, as follows:

    'MultiheadAttention',
    'TransformerEncoderLayer',
    'TransformerEncoder',
    'TransformerDecoderLayer',
    'TransformerDecoder',
    'Transformer'

XiaoguangHu01
XiaoguangHu01 previously approved these changes Aug 22, 2020
Copy link
Contributor

@XiaoguangHu01 XiaoguangHu01 left a comment

Choose a reason for hiding this comment

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

LGTM


from .activation import *
from .loss import *
from .conv import *
from .extension import *
from .activation import *
from .norm import *
from .transformer import *
Copy link
Contributor

Choose a reason for hiding this comment

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

大写的组网类,在paddle.nn下建别名,推荐用paddle.nn.Transformer

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. Thanks

python/paddle/nn/layer/transformer.py Outdated Show resolved Hide resolved

return (q, k, v) if cache is None else (q, k, v, cache)

def cal_kv(self, key, value):
Copy link
Contributor

Choose a reason for hiding this comment

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

calculate 的缩写用 calc 更多些

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. Rename as compute_kv. Thanks


return (q, k, v) if cache is None else (q, k, v, cache)

def cal_kv(self, key, value):
Copy link
Contributor

Choose a reason for hiding this comment

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

这个API用户是否需要使用?如果需要的话,建议修改下。
calculate 的缩写用 calc 更多些,或者这里用compute也可以

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. Rename as compute_kv. Thanks

iclementine
iclementine previously approved these changes Aug 22, 2020
Copy link

@iclementine iclementine left a comment

Choose a reason for hiding this comment

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

LGTM

import copy
import collections

import numpy as np

Choose a reason for hiding this comment

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

这里其实可以不必 import numpy

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. Thanks

@guoshengCS guoshengCS merged commit 317f7ce into PaddlePaddle:develop Aug 24, 2020
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.

5 participants