-
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
新动态图模式SGD下降结果与之前版本不一致 #49782
Comments
您好,我们已经收到了您的问题,会安排技术人员尽快解答您的问题,请耐心等待。请您再次检查是否提供了清晰的问题描述、复现代码、环境&版本、报错信息等。同时,您也可以通过查看官网API文档、常见问题、历史Issue、AI社区来寻求解答。祝您生活愉快~ Hi! We've received your issue and please be patient to get responded. We will arrange technicians to answer your questions as soon as possible. Please make sure that you have posted enough message to demo your request. You may also check out the API,FAQ,Github Issue and AI community to get the answer.Have a nice day! |
你好 在paddle2.4版本的SGD API 中新增了multi_precision参数,因此在调用的时候需要保证参数对应哟,避免出现计算错误的问题。https://www.paddlepaddle.org.cn/documentation/docs/en/api/paddle/optimizer/SGD_en.html |
问题没解决,这个项目里面有一个d2l的文件夹,里面paddle.py文件有一个train_ch6的函数,里面的SGD参数是有写参数名的,应该不是这个问题 def train_ch6(net, train_iter, test_iter, num_epochs, lr, device):
"""用GPU训练模型(在第六章定义)"""
def init_weights(m):
if type(m) == nn.Linear or type(m) == nn.Conv2D:
nn.initializer.XavierUniform(m.weight)
net.apply(init_weights)
print('training on', device)
net.to(device)
optimizer = paddle.optimizer.SGD(learning_rate=lr, parameters=net.parameters()) |
你好,可以尝试手动在SGD代码调用处修改in_dygraph_mode的调用,直接走老动态图的形式,进一步验证in_dygraph_mode的问题。
|
第一张图是2.4.1原版的SGD代码,第二张图将in_dygraph_mode()里面的算子换成了_legacy_C_ops,跑出来的结果,legacy是正常的,bug确实极大可能出现在新动态图模式的算子,下面附上notebook代码,可以用vscode直接打开跑。 |
好的 感谢提供,我会尽快进行本地复现的请稍等 |
你好 已经复现您说的现象,已联系相关api负责人 |
Since you haven't replied for more than a year, we have closed this issue/pr. |
bug描述 Describe the Bug
问题复现链接:https://aistudio.baidu.com/aistudio/projectdetail/5387434?sUid=168825&shared=1&ts=1673534614456
问题描述:2.4.0版本开始默认使用新动态图模式后,该项目SGD梯度下降的结果出现反向优化的情况。更换Adam、Momentum等优化器后,结果与2.3.2版本保持一致。经过代码对比后发现,2.4.0版本后SGD默认in_dygraph_mode()模式,底层部分代码改动较大,因此该部分出现BUG的概率比较大,希望官方能进一步排查。
以下分别为2.3.2,2.4.0,2.4.1版本下相同代码的结果,其中2.3.2为正常结果
其他补充信息 Additional Supplementary Information
No response
The text was updated successfully, but these errors were encountered: