# Dimension mismatch in Flux.jl RNN example

**URL:** <https://discourse.julialang.org/t/dimension-mismatch-in-flux-jl-rnn-example/122410>\
**Category:** Machine Learning\
**Created:** [November 8, 2024, 9:45am UTC](https://discourse.julialang.org/t/dimension-mismatch-in-flux-jl-rnn-example/122410 "2024-11-08T09:45:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![arinbasu1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/arinbasu1/32/45571_2.png) [@arinbasu1](https://discourse.julialang.org/u/arinbasu1)\
**Post date:** [November 8, 2024, 9:45am UTC](https://discourse.julialang.org/t/dimension-mismatch-in-flux-jl-rnn-example/122410/1 "2024-11-08T09:45:25Z")

</div>

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:

```julia
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, 🙂

Would greatly appreciate your advice.

Kind Regards,  
Arindam Basu

---

<div class="post-metadata">

**Author:** ![CarloLucibello](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carlolucibello/32/3278_2.png) [@CarloLucibello](https://discourse.julialang.org/u/CarloLucibello)\
**Post date:** [November 8, 2024, 11:12am UTC](https://discourse.julialang.org/t/dimension-mismatch-in-flux-jl-rnn-example/122410/2 "2024-11-08T11:12:59Z")

</div>

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](https://fluxml.ai/Flux.jl/stable/)

---

<div class="post-metadata">

**Author:** ![arinbasu1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/arinbasu1/32/45571_2.png) [@arinbasu1](https://discourse.julialang.org/u/arinbasu1)\
**Post date:** [November 8, 2024, 6:40pm UTC](https://discourse.julialang.org/t/dimension-mismatch-in-flux-jl-rnn-example/122410/3 "2024-11-08T18:40:34Z")

</div>

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