Can anyone please help with my sequence-to-one RNN. Here is where I am:

Each of my sequences consists of `seq_length`

vectors (with zero padding if necessary for shorter sequences), each of size `n_features`

, and if it makes sense for better performance, I want to pack several sequence into single tensor (to transfer to GPU with CUDA.jl as described in Flux doc) . So I’m having 3 dimensions (n_feature, seq_length, n_samples).

Having this data setup I want to design Layer (which is very similar to Flux.Recur), which also iterates though all time steps and outputs n_samples results. It all comes down to the following code:

```
mutable struct StepRNN{C, T}
cell::C # RNN cell
state::T # tensor of states for each of n_samples in batch
end
function (r::StepRNN)(x)
n_feature, seq_length, n_samples = size(x) # extract tensor size
reset!(r) # reset state of RNNCell to zeros, since we start new sequence processing
r.state, y = r.cell(r.state, x[:,1,:]) # step through time steps for all n_samples simultaneously
for i in 2:seq_length
r.state, y = r.cell(r.state, x[:,i,:])
end
return y # return results for each of n_samples
end
```

Does this design/code makes sense or can anyone please point me to better implementation of sequence-to-one with Flux? Or how can I fix/improve this code?

Thank you very much in advance,