Show_attend_tell.emadl 1.32 KB
Newer Older
1 2 3 4
package showAttendTell;

component Show_attend_tell{
    ports in Z(-oo:oo)^{64,2048} data,
5
         in Z(0:255)^{3,224,224} images,
6 7 8 9 10 11
         out Z(0:37758)^{1} target[25];

   implementation CNN{

      layer LSTM(units=512) decoder;

12
      layer FullyConnected(units = 256, flatten=false) features;
13 14
      layer FullyConnected(units = 1, flatten=false) attention;

15
      0 -> target[0];
16

17
      data -> features;
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41

       timed <t> GreedySearch(max_length=25){
        (
           (
               (
                 features.output ->
                 FullyConnected(units=512, flatten=false)
               |
                 decoder.state[0] ->
                 FullyConnected(units=512, flatten=false)
               ) ->
               BroadcastAdd() ->
               Tanh() ->
               FullyConnected(units=1, flatten=false) ->
               Softmax(axis=0) ->
               attention
           |
               features.output
           )->
           BroadcastMultiply() ->
           ReduceSum(axis=0) ->
           ExpandDims(axis=0)
           |
           target[t-1] ->
42
           Embedding(output_dim=256)
43 44 45 46
       ) ->
       Concatenate(axis=1) ->
       decoder ->
       FullyConnected(units=37758) ->
47
       Tanh() ->
48 49 50 51 52 53 54
       Dropout(p=0.25) ->
       Softmax() ->
       ArgMax() ->
       target[t]
       };
       }
 }
55