Created
March 20, 2021 21:22
-
-
Save adamoudad/9ae2075c8d2f24683a29d65adf36fe71 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def init_weights(self): | |
self.encoder.weight.data.uniform_(-0.5, 0.5) | |
ih = (param.data for name, param in self.named_parameters() if 'weight_ih' in name) | |
hh = (param.data for name, param in self.named_parameters() if 'weight_hh' in name) | |
b = (param.data for name, param in self.named_parameters() if 'bias' in name) | |
for t in ih: | |
nn.init.xavier_uniform(t) | |
for t in hh: | |
nn.init.orthogonal(t) | |
for t in b: | |
nn.init.constant(t, 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment