Skip to content

Commit

Permalink
add OrderedDict footnote in 5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ShusenTang committed Feb 10, 2020
1 parent e488294 commit 7787fc9
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/chapter5/5.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@ for name, param in seq_model.named_parameters():
```

实际上,`Sequential`中每个模块的名称都是该模块在参数中出现的顺序。有趣的是,`Sequential`还可以接受`OrderedDict`作为参数,这样就可以给`Sequential`的每个模块命名:

> 并非所有版本的Python都明确指定`dict`的迭代顺序,因此我们在这里使用`OrderedDict`来明确层的顺序并强调这个顺序的重要性。
``` python
from collections import OrderedDict

Expand Down

0 comments on commit 7787fc9

Please sign in to comment.