Example #1
0
def test_ind_lstm():
    a = C.sequence.input_variable(10)
    b = Recurrence(IndyLSTM(20))(a)

    assert b.shape == (20, )

    n = np.random.random((2, 6, 10)).astype(np.float32)
    b.eval({a: n})
Example #2
0
def test_weight_dropped_lstm():
    dropconnect_rate = 0.2
    variationaldrop_rate = 0.1
    a = C.sequence.input_variable(10)
    b = Recurrence(WeightDroppedLSTM(20, dropconnect_rate),
                   dropout_rate_input=variationaldrop_rate,
                   dropout_rate_output=variationaldrop_rate)(a)

    assert b.shape == (20, )

    n = np.random.random((2, 6, 10)).astype(np.float32)
    b.eval({a: n})
Example #3
0
    def gaussian_windows_attention_coefficients(abk, nb_mixtures):
        """ Split into 3 equal tensor of dim nb_mixtures """
        a = C.slice(abk, 0, 0, nb_mixtures)
        b = C.slice(abk, 0, nb_mixtures, 2 * nb_mixtures)
        k = C.slice(abk, 0, 2 * nb_mixtures, 0)
        k = Recurrence(C.plus)(k)

        a = C.expand_dims(a, axis=-1)
        b = C.expand_dims(b, axis=-1)
        k = C.expand_dims(k, axis=-1)
        return a, b, k
Example #4
0
def model_ind_rnn(input_tensor, hidden_dim):
    hidden = Recurrence(IndRNN(hidden_dim, C.relu))(input_tensor)
    prediction = Dense(1)(C.sequence.last(hidden))
    return prediction
Example #5
0
def model_indy_lstm(input_tensor, hidden_dim):
    hidden = Recurrence(IndyLSTM(hidden_dim))(input_tensor)
    prediction = Dense(1)(C.sequence.last(hidden))
    return prediction
Example #6
0
def model_wdlstm(input_tensor, hidden_dim, dropout):
    hidden = Recurrence(WeightDroppedLSTM(hidden_dim, dropout))(input_tensor)
    prediction = Dense(1)(C.sequence.last(hidden))
    return prediction