def init(self): # embeddings initialization.init_embeddings(self.embs) # rnn initialization.init_rnn(self.rnn, scheme=self.init_rnn) # linear initialization.init_linear(self.proj)
def __init__(self, num_embeddings, embedding_dim, padding_idx=None, custom_lstm=False, cell='LSTM', init_rnn='default', num_layers=1, dropout=0.0): self.num_embeddings = num_embeddings self.num_layers = num_layers self.embedding_dim = embedding_dim * 2 # bidirectional super().__init__() self.emb = nn.Embedding(num_embeddings, embedding_dim, padding_idx=padding_idx) initialization.init_embeddings(self.emb) if custom_lstm: self.rnn = CustomBiLSTM( embedding_dim, embedding_dim, num_layers=num_layers, dropout=dropout) else: self.rnn = getattr(nn, cell)( embedding_dim, embedding_dim, bidirectional=True, num_layers=num_layers, dropout=dropout if num_layers > 1 else 0) initialization.init_rnn(self.rnn, scheme=init_rnn)
def init(self): for rnn in self.rnn: initialization.init_rnn(rnn, scheme=self.init_rnn)
def init(self): initialization.init_rnn(self.rnn)