def __init__(self, params): super(Encoder, self).__init__() self.params = params self.hw1 = Highway(self.params.sum_depth + self.params.word_embed_size, 2, F.relu) self.rnn = nn.LSTM(input_size=self.params.word_embed_size + self.params.sum_depth, hidden_size=self.params.encoder_rnn_size, num_layers=self.params.encoder_num_layers, dropout=0.5, batch_first=True, bidirectional=True) self.hw2 = Highway(self.params.encoder_rnn_size * 2, 3, F.relu)
def __init__(self, params): super(Encoder, self).__init__() self.params = params self.hw1 = Highway(self.params.sum_depth + self.params.word_embed_size, 2, F.relu) self.rnn = nn.LSTM(input_size=self.params.word_embed_size + self.params.sum_depth, hidden_size=self.params.encoder_rnn_size, num_layers=self.params.encoder_num_layers, batch_first=True, bidirectional=True) self.hw2 = Highway(self.rnn.hidden_size * 2, 2, F.relu) self.fc = nn.Linear(self.rnn.hidden_size * 2, self.params.latent_variable_size)
def __init__(self, params): super(Encoder, self).__init__() self.params = params isize = ( self.params.sum_depth + self.params.word_embed_size ) if not self.params.word_is_char else self.params.word_embed_size self.hw1 = Highway(isize, 10, F.relu) if self.params.use_highway else None self.rnn = nn.LSTM(input_size=isize, hidden_size=self.params.encoder_rnn_size, num_layers=self.params.encoder_num_layers, batch_first=True, bidirectional=True) self.hw2 = Highway(self.params.encoder_rnn_size * 2, 20, F.relu) if self.params.use_highway else None
def __init__(self, params): super(Inference, self).__init__() self.params = params self.rnn = nn.GRU(input_size=self.params.word_embed_size, hidden_size=self.params.encoder_size, num_layers=self.params.encoder_num_layers, batch_first=True, bidirectional=True) self.highway = Highway(self.params.encoder_size * 2, 3, F.elu)
def __init__(self, params): super(Generator, self).__init__() self.params = params self.rnn = nn.GRU(input_size=self.params.latent_variable_size + self.params.word_embed_size, hidden_size=self.params.decoder_size, num_layers=self.params.decoder_num_layers, batch_first=True) self.highway = Highway(self.params.decoder_size, 3, F.elu) self.fc = nn.Linear(self.params.decoder_size, self.params.word_embed_size)
def __init__(self, params): super(DecoderLSTM, self).__init__() self.params = params self.rnn = nn.LSTM(input_size=self.params.latent_variable_size + self.params.word_embed_size, hidden_size=self.params.decoder_rnn_size, num_layers=self.params.decoder_num_layers, batch_first=True) self.highway = Highway(self.params.decoder_rnn_size, 10, F.elu) if self.params.use_highway else None self.fc = nn.Linear(self.params.decoder_rnn_size, self.params.word_vocab_size)
def __init__(self, params): super(OriginalEncoder, self).__init__() self.params = params self.bidirectional = self.params.bidirectional self.hw1 = Highway(self.params.sum_depth + self.params.word_embed_size, 2, F.relu) self.rnn = nn.LSTM(input_size=self.params.word_embed_size + self.params.sum_depth, hidden_size=self.params.encoder_rnn_size, num_layers=self.params.encoder_num_layers, batch_first=True, bidirectional=self.bidirectional) self.mul_factor = 2 if not self.bidirectional: self.mul_factor = 1
def __init__(self, params): super(EncoderHR, self).__init__() self.params = params self.hw1 = Highway(self.params.sum_depth + self.params.word_embed_size, 2, F.relu) self.bi = True self.rnn = nn.LSTM( input_size=self.params.word_embed_size + self.params.sum_depth, hidden_size=self.params.encoder_rnn_size, num_layers=self.params.encoder_num_layers, batch_first=True, bidirectional=self.bi, ) self.layer_dim = (self.params.encoder_num_layers * 2) * self.params.encoder_rnn_size self.linear_mu = nn.Linear(self.layer_dim * 2, self.layer_dim * 2) self.linear_var = nn.Linear(self.layer_dim * 2, self.layer_dim * 2)