Dimension mismatch in Flux.jl RNN example

I was trying to run an RNN model in Flux and came up with an error in the RNN model. This error also occurred in the RNN example from Flux’s documentation site:

Here is the code:

using Flux

output_size = 5
input_size = 2
seq_len = 3
x = [rand(Float32, input_size) for i = 1:seq_len] 
h0 = zeros(Float32, output_size) 

rnn_cell = Flux.RNNCell(input_size => output_size)

y = []
ht = h0
for xt in x
    ht = rnn_cell(xt, ht)
    y = [y; [ht]]
end

& here is the error message

DimensionMismatch: layer RNNCell(2 => 5, tanh) expects size(input, 1) == 2, but got 5-element Vector{Float32}

Apparently the dimension mismatch issue is with the rnn_cell(xt, ht)

If I reverse the order of xt and ht (why would I?) the code runs oh well, :slight_smile:

Would greatly appreciate your advice.

Kind Regards,
Arindam Basu

I think that you are reading the documentation for the next breaking release (v0.15, not tagged yet) while staying on v0.14.

The documentation for the latest release is found here

1 Like

Ok, got it. The stable release documentation worked just fine.