def lstm(X, encoder):
    layers = [
        (InputLayer, {}),
        (EmbeddingLayer, {
            'output_size': 32
        }),
        (LSTMLayer, {
            'grad_clipping': 5.,
            'num_units': 100
        }),
        (LSTMLayer, {
            'grad_clipping': 5.,
            'num_units': 100
        }),
        (RNNDenseLayer, {
            'nonlinearity': identity
        }),
    ]
    rnn = RNN(
        layers=layers,
        encoder=encoder,
        verbose=1,
        improvement_threshold=1.,
        updater=partial(rmsprop, learning_rate=1e-2),
    )
    rnn.initialize()
    return rnn
Beispiel #2
0
 def clf(self, encoder):
     clf = RNN(encoder=encoder, **rnn_kwargs())
     clf.initialize()
     clf.fit(self.X, num_epochs=1)
     return clf
Beispiel #3
0
 def test_init_raises_when_patience_and_no_eval(self):
     with pytest.raises(ValueError):
         RNN(layers=[], encoder=Mock(), patience=3, eval_size=0)