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

【Hackathon 5th No.12】Add AdaptiveLogSoftmaxWithLoss API to Paddle #59623

Closed
wants to merge 3 commits into from

Conversation

Patrick-Star125
Copy link
Contributor

PR types

New features

PR changes

APIs

Description

Add AdaptiveLogSoftmaxWithLoss API to Paddle

Link

Rfc PR: PaddlePaddle/community#770
docs PR: PaddlePaddle/docs#6346

待完成

  • RFC文档修改
  • 中文文档

Copy link

paddle-bot bot commented Dec 2, 2023

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@Patrick-Star125
Copy link
Contributor Author

Patrick-Star125 commented Dec 3, 2023

在静态图中使用create_parameter创建tensor会报错显示未初始化

InvalidArgumentError: The phi::DenseTensor in the matmul_v2 Op's Input Variable Y(adaptive_log_softmax_with_loss_0.w_0) is not initialized.
[Hint: Expected t->IsInitialized() == true, but received t->IsInitialized():0 != true:1.] (at ..\paddle\fluid\framework\operator.cc:2950)
[operator < matmul_v2 > error]

我尝试使用直接创建tensor的方式替换逻辑,但是计算结果是错误的

请问静态图中create_parameter的初始化是要做其它的处理吗

self.n_clusters = len(self.cutoffs) - 1
self.head_size = self.shortlist_size + self.n_clusters

if paddle.in_dynamic_mode():
Copy link
Contributor

Choose a reason for hiding this comment

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

这个在底层区分了动态图和静态图,不需要这么写,而且下面的这种创建可训练参数也是不合理的,之前报错未初始化的问题有没有更完整的报错,可以开一下glog看看日志(GLOG_v=6)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

这个问题报错的位置并不在初始化的地方,而是在初始化之后第一个运算函数中报错,例如elementwise_add或者matmul_v2,都是和下面的报错类似

InvalidArgumentError: The phi::DenseTensor in the matmul_v2 Op's Input Variable Y(adaptive_log_softmax_with_loss_0.w_0) is not initialized.
[Hint: Expected t->IsInitialized() == true, but received t->IsInitialized():0 != true:1.] (at ..\paddle\fluid\framework\operator.cc:2950)
[operator < matmul_v2 > error]

请问如何创建可训练参数比较合理?从功能角度来讲我能否不创建参数,直接用手动创建的Tensor替代?

Copy link
Contributor

Choose a reason for hiding this comment

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

你上面的create_parameter 这种方式就是合理的,但是其实你可以不用这么操作,你的head_weight和head_bias 应该是线性层的参数,那么你其实可以创建一个linear 的 sublayer,这两个参数就是这个子层的参数,直接拿过来用就行了

Copy link

paddle-ci-bot bot commented Dec 29, 2023

Sorry to inform you that fedcd3b's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually.

@luotao1 luotao1 closed this Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants