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

[PyTorch] Fix module types (LazyLinear -> Linear) #2225

Merged
merged 1 commit into from
Jul 31, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions chapter_builders-guide/init-param.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ net[0].weight.data()[0]
```{.python .input n=6}
%%tab pytorch
def init_normal(module):
if type(module) == nn.LazyLinear:
if type(module) == nn.Linear:
nn.init.normal_(module.weight, mean=0, std=0.01)
nn.init.zeros_(module.bias)
net.apply(init_normal)
Expand Down Expand Up @@ -122,7 +122,7 @@ net[0].weight.data()[0]
```{.python .input n=9}
%%tab pytorch
def init_constant(module):
if type(module) == nn.LazyLinear:
if type(module) == nn.Linear:
nn.init.constant_(module.weight, 1)
nn.init.zeros_(module.bias)
net.apply(init_constant)
Expand Down Expand Up @@ -161,10 +161,10 @@ print(net[1].weight.data())
```{.python .input n=12}
%%tab pytorch
def init_xavier(module):
if type(module) == nn.LazyLinear:
if type(module) == nn.Linear:
nn.init.xavier_uniform_(module.weight)
def init_42(module):
if type(module) == nn.LazyLinear:
if type(module) == nn.Linear:
nn.init.constant_(module.weight, 42)

net[0].apply(init_xavier)
Expand Down Expand Up @@ -238,7 +238,7 @@ net[0].weight.data()[:2]
```{.python .input n=15}
%%tab pytorch
def my_init(module):
if type(module) == nn.LazyLinear:
if type(module) == nn.Linear:
print("Init", *[(name, param.shape)
for name, param in module.named_parameters()][0])
nn.init.uniform_(module.weight, -10, 10)
Expand Down