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

Please add "stop_gradient" parameter into paddle.create_parameter() #68707

Open
ILoveAmy opened this issue Oct 15, 2024 · 2 comments
Open

Please add "stop_gradient" parameter into paddle.create_parameter() #68707

ILoveAmy opened this issue Oct 15, 2024 · 2 comments
Assignees
Labels

Comments

@ILoveAmy
Copy link

ILoveAmy commented Oct 15, 2024

需求描述 Feature Description

To make the code more concise and elegant, Please add "stop_gradient" parameter into paddle.create_parameter()

import paddle
# 初始化权重参数,设置为不需要梯度
W_query = paddle.create_parameter(shape=[2, 6], dtype='float32', default_initializer=paddle.nn.initializer.Uniform(), stop_gradient=False)

1728961285577

Currently, we have to implement the code as below, TWO lines!.

import paddle
# 初始化权重参数,设置为不需要梯度
W_query = paddle.create_parameter(shape=[d_in, d_out], dtype='float32', default_initializer=paddle.nn.initializer.Uniform())
W_query.stop_gradient = True

However, We can implement it using only ONE line PyTorch code

W_query = torch.nn.Parameter(torch.rand(2, 6), requires_grad=False)

@ZhangHandi
Copy link
Contributor

Thanks for your feedback. Currently, you need to use combination of code instead of implementation directly as mentioned in this tutorial create_parameter and I will feedback this issue to the corresponding developer.

@ILoveAmy
Copy link
Author

Thanks for your feedback. Currently, you need to use combination of code instead of implementation directly as mentioned in this tutorial create_parameter and I will feedback this issue to the corresponding developer.

Thank you very much! Looking forward to Paddle's concise implementation of paddle.create_parameter()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants