-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Update initializer examples of Bilinear #27709
Conversation
Thanks for your contribution! |
python/paddle/fluid/initializer.py
Outdated
regularizer=L2Decay(0.), | ||
initializer=nn.initializer.Bilinear()) | ||
data = np.random.uniform(-1, 1, [30, 10, 32]).astype('float32') | ||
data = paddle.to_tensor(data) |
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.
这里直接用paddle.rand
吧。
上面也不需要import numpy和disable_static了。
另外上面的where, ... 那部分描述还要留着呀。
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.
好的,已经完成了
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.
paddle.rand返回已经是个tensor,所以不用data = paddle.to_tensor(data),请删除745行
python/paddle/fluid/initializer.py
Outdated
@@ -729,31 +729,32 @@ class BilinearInitializer(Initializer): | |||
|
|||
.. code-block:: python | |||
|
|||
import paddle.fluid as fluid | |||
import paddle |
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.
Suggest to change import order. Usually we group the imports by function, then sort it by alphabetical order. Here import math
is in the middle of import paddle, which is ugly.
Suggest to change like this:
import math
import paddle
import paddle.nn
from paddle.regularizer import L2Decay
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.
I've already modified.
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.
Could you just put in order? You changed it like:
import xxx
from xxx import
import xxx
Why can't you just make it pretty? Since all xxx are paddle
import xxx
import xxx
from xxx import
python/paddle/fluid/initializer.py
Outdated
regularizer=L2Decay(0.), | ||
initializer=nn.initializer.Bilinear()) | ||
data = np.random.uniform(-1, 1, [30, 10, 32]).astype('float32') | ||
data = paddle.to_tensor(data) |
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.
paddle.rand返回已经是个tensor,所以不用data = paddle.to_tensor(data),请删除745行
python/paddle/fluid/initializer.py
Outdated
regularizer=L2Decay(0.), | ||
initializer=nn.initializer.Bilinear()) | ||
data = paddle.rand([B, 3, H, W], dtype='float32') | ||
#data = paddle.to_tensor(data) |
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.
Delete, not comment. Why comment? This example code is used for user reading, if you put comment here, it may confuse user!
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.
Already delete.
python/paddle/fluid/initializer.py
Outdated
@@ -729,31 +729,32 @@ class BilinearInitializer(Initializer): | |||
|
|||
.. code-block:: python | |||
|
|||
import paddle.fluid as fluid | |||
import paddle |
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.
Could you just put in order? You changed it like:
import xxx
from xxx import
import xxx
Why can't you just make it pretty? Since all xxx are paddle
import xxx
import xxx
from xxx import
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.
LGTM
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.
lgtm
PR types
Function optimization
PR changes
APIs
Describe
Update initializer examples of Bilinear