Esempio n. 1
0
 def __init__(self, lstm_hiddens, mlp_arc_size, mlp_rel_size, dropout_mlp, debug=False):
     super().__init__()
     self.dropout_mlp = dropout_mlp
     mlp_size = mlp_arc_size + mlp_rel_size
     W = orthonormal_initializer(mlp_size, 2 * lstm_hiddens, debug)
     self.mlp_dep_W = parameter_from_numpy(self, 'mlp_dep_W', W)
     self.mlp_dep_b = parameter_init(self, 'mlp_dep_b', (mlp_size,), mx.init.Zero())
     self.mlp_head_W = parameter_from_numpy(self, 'mlp_head_W', W)
     self.mlp_head_b = parameter_init(self, 'mlp_head_b', (mlp_size,), mx.init.Zero())
     self.mlp_rel_size = mlp_rel_size
     self.mlp_arc_size = mlp_arc_size
Esempio n. 2
0
 def __init__(self, vocab,
              mlp_arc_size,
              mlp_rel_size):
     super(BiAffine, self).__init__()
     self._vocab = vocab
     self.binary_ce_loss = SigmoidBinaryCrossEntropyLoss(batch_axis=-1)
     self.rel_W = parameter_init(self, 'rel_W', (vocab.rel_size * (mlp_rel_size + 1), mlp_rel_size + 1),
                                 init=mx.init.Zero())
     self.arc_W = parameter_init(self, 'arc_W', (mlp_arc_size, mlp_arc_size + 1), init=mx.init.Zero())
     self.softmax_loss = SoftmaxCrossEntropyLoss(axis=0, batch_axis=-1)
     self.mlp_arc_size = mlp_arc_size
     self.mlp_rel_size = mlp_rel_size
Esempio n. 3
0
 def __init__(self, vocab: List[ParserVocabulary], word_dims, tag_dims, dropout_dim, lstm_layers, lstm_hiddens,
              dropout_lstm_input, dropout_lstm_hidden, mlp_arc_size, mlp_rel_size, dropout_mlp, transfer=False,
              bert=0, debug=False):
     super().__init__(vocab, word_dims, tag_dims, dropout_dim, lstm_layers, lstm_hiddens, dropout_lstm_input,
                      dropout_lstm_hidden, mlp_arc_size, mlp_rel_size, dropout_mlp, transfer, bert, debug)
     self.weights = parameter_init(self, 'score_weight', (len(vocab), len(vocab)), mx.init.One())
     self.arc_biaffines = nn.Sequential()
     for voc in vocab:
         self.arc_biaffines.add(UnlabeledBiAffine(mlp_arc_size))
Esempio n. 4
0
 def __init__(self, vocab: List[ParserVocabulary], word_dims, tag_dims, dropout_dim, lstm_layers, lstm_hiddens,
              dropout_lstm_input, dropout_lstm_hidden, mlp_arc_size, mlp_rel_size, dropout_mlp, debug=False):
     super().__init__(vocab, word_dims, tag_dims, dropout_dim, lstm_layers, lstm_hiddens, dropout_lstm_input,
                      dropout_lstm_hidden, mlp_arc_size, mlp_rel_size, dropout_mlp, debug)
     self.shared_arc_W = parameter_init(self, 'arc_W', (mlp_arc_size, mlp_arc_size), init=mx.init.Xavier())
Esempio n. 5
0
 def __init__(self, mlp_arc_size):
     super().__init__()
     self.binary_ce_loss = SigmoidBinaryCrossEntropyLoss(batch_axis=-1)
     self.arc_W = parameter_init(self, 'arc_W', (mlp_arc_size, mlp_arc_size + 1), init=mx.init.Zero())
     self.mlp_arc_size = mlp_arc_size