Skip to content

Commit

Permalink
handle nn.init.orthogonal_ for pytorch v4
Browse files Browse the repository at this point in the history
  • Loading branch information
flennerhag committed May 24, 2018
1 parent e938af1 commit f408acc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions alstm/alstm.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,10 @@ def __init__(self, input_size, hidden_size, use_bias=True):

def reset_parameters(self):
"""Initialization of parameters"""
nn.init.orthogonal(self.weight_ih)
nn.init.orthogonal(self.weight_hh)
# Hack for handling PyTorch v4 moving to orthogonal_
f = getattr(torch.nn.init, 'orthogonal_', torch.nn.init.orthogonal)
f(self.weight_ih)
f(self.weight_hh)
if self.use_bias:
self.bias.data.zero_()
# Forget gate bias initialization
Expand Down

0 comments on commit f408acc

Please sign in to comment.