Ejemplo n.º 1
0
    init_h3.tag.test_value = np_zeros((minibatch_size, n_hid))

    init_kappa = tensor.matrix("init_kappa")
    init_kappa.tag.test_value = np_zeros((minibatch_size, att_size))

    init_w = tensor.matrix("init_w")
    init_w.tag.test_value = np_zeros((minibatch_size, n_chars))

    params = []
    biases = []

    cell1 = GRU(input_dim, n_hid, random_state)
    cell2 = GRU(n_hid, n_hid, random_state)
    cell3 = GRU(n_hid, n_hid, random_state)

    params += cell1.get_params()
    params += cell2.get_params()
    params += cell3.get_params()

    inp_to_h1 = GRUFork(input_dim, n_hid, random_state)
    inp_to_h2 = GRUFork(input_dim, n_hid, random_state)
    inp_to_h3 = GRUFork(input_dim, n_hid, random_state)
    att_to_h1 = GRUFork(n_chars, n_hid, random_state)
    att_to_h2 = GRUFork(n_chars, n_hid, random_state)
    att_to_h3 = GRUFork(n_chars, n_hid, random_state)
    h1_to_h2 = GRUFork(n_hid, n_hid, random_state)
    h1_to_h3 = GRUFork(n_hid, n_hid, random_state)
    h2_to_h3 = GRUFork(n_hid, n_hid, random_state)

    params += inp_to_h1.get_params()
    params += inp_to_h2.get_params()
    init_h3.tag.test_value = np_zeros((minibatch_size, n_hid))

    init_kappa = tensor.matrix("init_kappa")
    init_kappa.tag.test_value = np_zeros((minibatch_size, att_size))

    init_w = tensor.matrix("init_w")
    init_w.tag.test_value = np_zeros((minibatch_size, n_chars))

    params = []
    biases = []

    cell1 = GRU(input_dim, n_hid, random_state)
    cell2 = GRU(n_hid, n_hid, random_state)
    cell3 = GRU(n_hid, n_hid, random_state)

    params += cell1.get_params()
    params += cell2.get_params()
    params += cell3.get_params()

    inp_to_h1 = GRUFork(input_dim, n_hid, random_state)
    inp_to_h2 = GRUFork(input_dim, n_hid, random_state)
    inp_to_h3 = GRUFork(input_dim, n_hid, random_state)
    att_to_h1 = GRUFork(n_chars, n_hid, random_state)
    att_to_h2 = GRUFork(n_chars, n_hid, random_state)
    att_to_h3 = GRUFork(n_chars, n_hid, random_state)
    h1_to_h2 = GRUFork(n_hid, n_hid, random_state)
    h1_to_h3 = GRUFork(n_hid, n_hid, random_state)
    h2_to_h3 = GRUFork(n_hid, n_hid, random_state)

    params += inp_to_h1.get_params()
    params += inp_to_h2.get_params()
                                 random_state)
    b_conv1, = make_biases((n_kernels,))
    w_conv2, = make_conv_weights(n_kernels, (n_kernels,),
                                 (conv_size2, 1), random_state)
    b_conv2, = make_biases((n_kernels,))
    params += [w_conv1, b_conv1, w_conv2, b_conv2]

    # Use GRU classes only to fork 1 inp to 2 inp:gate pairs
    conv_to_h1 = GRUFork(n_kernels, n_hid, random_state)
    conv_to_h2 = GRUFork(n_kernels, n_hid, random_state)
    params += conv_to_h1.get_params()
    params += conv_to_h2.get_params()

    cell1 = GRU(n_kernels, n_hid, random_state)
    cell2 = GRU(n_hid, n_hid, random_state)
    params += cell1.get_params()
    params += cell2.get_params()

    # Use GRU classes only to fork 1 inp to 2 inp:gate pairs
    att_to_h1 = GRUFork(n_chars, n_hid, random_state)
    att_to_h2 = GRUFork(n_chars, n_hid, random_state)
    h1_to_h2 = GRUFork(n_hid, n_hid, random_state)

    params += att_to_h1.get_params()
    params += att_to_h2.get_params()
    params += h1_to_h2.get_params()

    h1_to_att_a, h1_to_att_b, h1_to_att_k = make_weights(n_hid, 3 * [att_size],
                                                         random_state)
    params += [h1_to_att_a, h1_to_att_b, h1_to_att_k]
Ejemplo n.º 4
0
                                 random_state)
    b_conv1, = make_biases((n_kernels, ))
    w_conv2, = make_conv_weights(n_kernels, (n_kernels, ), (conv_size2, 1),
                                 random_state)
    b_conv2, = make_biases((n_kernels, ))
    params += [w_conv1, b_conv1, w_conv2, b_conv2]

    # Use GRU classes only to fork 1 inp to 2 inp:gate pairs
    conv_to_h1 = GRUFork(n_kernels, n_hid, random_state)
    conv_to_h2 = GRUFork(n_kernels, n_hid, random_state)
    params += conv_to_h1.get_params()
    params += conv_to_h2.get_params()

    cell1 = GRU(n_kernels, n_hid, random_state)
    cell2 = GRU(n_hid, n_hid, random_state)
    params += cell1.get_params()
    params += cell2.get_params()

    # Use GRU classes only to fork 1 inp to 2 inp:gate pairs
    att_to_h1 = GRUFork(n_chars, n_hid, random_state)
    att_to_h2 = GRUFork(n_chars, n_hid, random_state)
    h1_to_h2 = GRUFork(n_hid, n_hid, random_state)

    params += att_to_h1.get_params()
    params += att_to_h2.get_params()
    params += h1_to_h2.get_params()

    h1_to_att_a, h1_to_att_b, h1_to_att_k = make_weights(
        n_hid, 3 * [att_size], random_state)
    params += [h1_to_att_a, h1_to_att_b, h1_to_att_k]