Commit 993f926a authored by Gustaf Ahdritz's avatar Gustaf Ahdritz
Browse files

Add no-grad block

parent ce27a6ca
...@@ -149,6 +149,7 @@ class Linear(nn.Linear): ...@@ -149,6 +149,7 @@ class Linear(nn.Linear):
with torch.no_grad(): with torch.no_grad():
self.bias.fill_(0) self.bias.fill_(0)
with torch.no_grad():
if init_fn is not None: if init_fn is not None:
init_fn(self.weight, self.bias) init_fn(self.weight, self.bias)
else: else:
...@@ -161,7 +162,6 @@ class Linear(nn.Linear): ...@@ -161,7 +162,6 @@ class Linear(nn.Linear):
elif init == "gating": elif init == "gating":
gating_init_(self.weight) gating_init_(self.weight)
if bias: if bias:
with torch.no_grad():
self.bias.fill_(1.0) self.bias.fill_(1.0)
elif init == "normal": elif init == "normal":
normal_init_(self.weight) normal_init_(self.weight)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment