RNNsearch.cnna 1.1 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
architecture RNNsearch {
    def input Z(0:29999)^{30} source
    def output Z(0:29999)^{1} target[30]

    layer GRU(units=1000, bidirectional=true) encoder;

    source ->
    Embedding(output_dim=500) ->
    encoder;

    1 -> target[0];

    layer GRU(units=1000) decoder;

    encoder.state -> Split(n=2) -> Get(index=1) -> decoder.state;

    timed<t> BeamSearch(max_length=30, width=3) {
       (
            (
                (
                    decoder.state ->
                    Repeat(n=30, axis=0)
                |
                    encoder.output
                ) ->
                Concatenate(axis=1) ->
                FullyConnected(units=1000, flatten=false) ->
                Tanh() ->
                FullyConnected(units=30) ->
                Softmax() ->
                ExpandDims(axis=0)
            |
                encoder.output
            ) ->
            Dot()
        |
            target[t-1] ->
            Embedding(output_dim=500)
        ) ->
        Concatenate(axis=1) ->
        decoder ->
        FullyConnected(units=30000) ->
        ArgMax() ->
        target[t]
    };
}