How to build Stacked RNN in Flux.jl?

How to build Stacked RNN in Flux.jl?

Is the following code the correct way?

using Flux
model = Chain(GRUv3(27 => 32),GRUv3(32 => 32),Dense(32 => 27))
Chain(
  Recur(
    GRUv3Cell(27 => 32),                # 5_792 parameters
  ),
  Recur(
    GRUv3Cell(32 => 32),                # 6_272 parameters
  ),
  Dense(32 => 27),                      # 891 parameters
)         # Total: 12 trainable arrays, 12_955 parameters,
          # plus 2 non-trainable, 64 parameters, summarysize 1.938 KiB.

Yes I think you have it correct!
You may want to have a Embedding or Dense as first operator to reproject the input data to the 27 dimensions expected by the GRU cell, but otherwise it looks fine.

1 Like