Skip to content

[Doc Link Fix No.100] Fix docs link in page torch.optim.Optimizer.state_dict.md#7780

Open
ShigureNyako wants to merge 2 commits intoPaddlePaddle:developfrom
ShigureNyako:fix/link-optimizer-state-dict-20260227
Open

[Doc Link Fix No.100] Fix docs link in page torch.optim.Optimizer.state_dict.md#7780
ShigureNyako wants to merge 2 commits intoPaddlePaddle:developfrom
ShigureNyako:fix/link-optimizer-state-dict-20260227

Conversation

@ShigureNyako
Copy link
Contributor

@ShigureNyako ShigureNyako commented Feb 26, 2026

@paddle-bot
Copy link

paddle-bot bot commented Feb 26, 2026

感谢你贡献飞桨文档,文档预览构建中,Docs-New 跑完后即可预览,预览链接:http://preview-pr-7780.paddle-docs-preview.paddlepaddle.org.cn/documentation/docs/zh/api/index_cn.html
预览工具的更多说明,请参考:飞桨文档预览工具

@ShigureNyako
Copy link
Contributor Author

@SigureMo 已自查 diff:仅修复 1 处失效链接(会跳到 docs 首页 -> 正确 API 锚点),辛苦 review 一下喵~

@github-actions
Copy link

github-actions bot commented Feb 26, 2026

📚 本次 PR 文档预览链接(点击展开)
ℹ️ 预览提醒
请等待 Docs-NEW 流水线运行完成后再点击预览链接,否则可能会看到旧版本内容或遇到链接无法访问的情况。
  • docs/api/paddle/optimizer/Optimizer_cn.rst: 点击预览
  • docs/guides/model_convert/convert_from_pytorch/api_difference/invok_only_diff/torch.optim.Optimizer.load_state_dict.md: 点击预览
  • docs/guides/model_convert/convert_from_pytorch/api_difference/invok_only_diff/torch.optim.Optimizer.state_dict.md: 点击预览

Copy link
Member

@SigureMo SigureMo left a comment

Choose a reason for hiding this comment

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

这不对吧?

@ShigureNyako ShigureNyako force-pushed the fix/link-optimizer-state-dict-20260227 branch from 83565f5 to 466ec3c Compare February 28, 2026 14:36
@ShigureNyako
Copy link
Contributor Author

已修复,之前误将链接改为了不完整的相对路径,现已替换为英文 API 文档链接(中文文档页面无 state_dict 锚点,因此使用英文文档):

  • https://www.paddlepaddle.org.cn/documentation/docs/en/api/paddle/optimizer/Optimizer_en.html#state_dict

@SigureMo 再看看~ 🐱

```

### [paddle.optimizer.Optimizer.state_dict](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/optimizer/Optimizer/state_dict_cn.html#paddle/optimizer/Optimizer/state_dict_cn#cn-api-paddle-optimizer-Optimizer-state_dict)
### [paddle.optimizer.Optimizer.state_dict](https://www.paddlepaddle.org.cn/documentation/docs/en/api/paddle/optimizer/Optimizer_en.html#state_dict)
Copy link
Member

Choose a reason for hiding this comment

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

我觉得我们还应该调整一下:

  • 对于有中文文档的 API,直接将中文文档贴上
  • 对于没有中文文档但有英文文档的 API,意味着该 API 明明是公开 API,但该 API 遗失了中文文档,你应该补充中文文档(从英文文档翻译而来,格式按照参考其他中文文档),并将中文文档贴上去
  • 对于中英文文档都没有的,意味着该 API 非公开 API,直接贴 GitHub 源码的 permalink

这个 PR 按照上面说的来搞一下吧,顺带 #7782 的中文文档也在这个 PR 补一下吧

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已按照你的建议修改:

  1. 补充了中文文档:在 Optimizer_cn.rst 中补充了 state_dict()set_state_dict()load_state_dict() 三个方法的中文文档(从英文文档翻译而来,格式参考了现有方法的格式)
  2. 更新了 state_dict 链接:改为指向中文文档 Optimizer_cn.html#state-dict
  3. 更新了 load_state_dict 链接[Doc Link Fix No.99] Fix docs link in page torch.optim.Optimizer.load_state_dict.md #7782 的内容):改为指向中文文档 Optimizer_cn.html#load-state-dict-state-dict

Copy link
Member

@SigureMo SigureMo left a comment

Choose a reason for hiding this comment

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

冲突了啊,得解决下

另外这种添加中文文档的,记得在 PR 描述指出英文文档在哪

@ShigureNyako ShigureNyako force-pushed the fix/link-optimizer-state-dict-20260227 branch from 0268d17 to 4cabe03 Compare February 28, 2026 15:16
@ShigureNyako
Copy link
Contributor Author

已解决冲突并更新了 PR 描述,补充了英文文档链接说明,详见 PR 描述中的「补充的中文文档」部分。

@ShigureNyako
Copy link
Contributor Author

@SigureMo 确认过了,这个 anchor 是正确的喵~

在 中, 的方法标题是 load_state_dict(state_dict)(包含参数),Sphinx 会将其转换为 load-state-dict-state-dict 的 anchor。

对比同文件中的其他方法:

  • state_dict()#state-dict(不含参数)
  • set_state_dict(state_dict)#set-state-dict-state-dict(含参数)
  • load_state_dict(state_dict)#load-state-dict-state-dict(含参数)

所以当前链接 Optimizer_cn.html#load-state-dict-state-dict 是正确的!🧵🐱

@ShigureNyako
Copy link
Contributor Author

补充说明:在 Optimizer_cn.rst 中,方法标题格式决定了 anchor:

  • state_dict() → #state-dict(无参数)
  • set_state_dict(state_dict) → #set-state-dict-state-dict(含参数)
  • load_state_dict(state_dict) → #load-state-dict-state-dict(含参数)

当前链接是正确的 ✅

Copy link
Member

@SigureMo SigureMo left a comment

Choose a reason for hiding this comment

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

其他没啥问题了


**代码示例**

COPY-FROM: paddle.optimizer.Optimizer.load_state_dict
Copy link
Member

Choose a reason for hiding this comment

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

顺序和英文文档保持一致吧,这三个 API 挪到 get_lr 之前

…ict and fix links

- Add state_dict(), set_state_dict(), load_state_dict() methods to Optimizer_cn.rst
- Update state_dict mapping link to Chinese docs
- Update load_state_dict mapping link to Chinese docs (from PaddlePaddle#7782)
@ShigureNyako ShigureNyako force-pushed the fix/link-optimizer-state-dict-20260227 branch from 4cabe03 to 5e9fbaf Compare February 28, 2026 16:29
Copy link
Contributor Author

@ShigureNyako ShigureNyako left a comment

Choose a reason for hiding this comment

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

已调整顺序,将 state_dict/set_state_dict/load_state_dict 移到 get_lr 之前,与英文文档保持一致

@ShigureNyako
Copy link
Contributor Author

已修复 review 意见:将 state_dict/set_state_dict/load_state_dict 三个 API 移到 get_lr 之前,与英文文档顺序保持一致。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants