# Issue with LSTM with Flux

**URL:** https://discourse.julialang.org/t/issue-with-lstm-with-flux/73563
**Category:** Performance
**Tags:** flux, time-series, machine-learning, lstm
**Created:** [December 23, 2021, 11:54pm UTC](https://discourse.julialang.org/t/issue-with-lstm-with-flux/73563 "2021-12-23T23:54:41Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Vishal\_Sharma1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vishal_sharma1/32/26553_2.png) [@Vishal\_Sharma1](https://discourse.julialang.org/u/Vishal_Sharma1)
#### Post date: [December 23, 2021, 11:54pm UTC](https://discourse.julialang.org/t/issue-with-lstm-with-flux/73563/1 "2021-12-23T23:54:41Z")

</div>

I am new to Flux and trying to get LSTM model for a time series prediction working but currently stuck at an error which I dont seem to understand.

> train\_data, train\_labels, test\_data, test\_labels = getData(df)  
> model = Chain(LSTM(60, 10), Dense(10, 1))
> 
> loss(x, y) = Flux.mse(model(x), y)
> 
> ps = Flux.params(model)
> 
> opt = Flux.ADAM()
> 
> for epochNum = 1: 10  
> Flux.reset!(model)  
> Flux.train!(loss, ps, zip(train\_data, train\_labels), opt)  
> end

The error that I get is

> MethodError: no method matching ChainRulesCore.InplaceableThunk(::NNlib.var"#50#53"{Matrix{Float32}, Matrix{Float32}}, ::ChainRulesCore.Thunk{NNlib.var"#51#54"{Matrix{Float32}, Matrix{Float32}}})  
> Closest candidates are:  
> ChainRulesCore.InplaceableThunk(::T, ::F) where {T\<:ChainRulesCore.Thunk, F} at  
> C:\Users\vs\.julia\packages\ChainRulesCore\EgLlm\src\differentials\thunks.jl:206

Each data point of train\_data is 60 element vector like

> Float32[0.0, 0.0009504938, -0.005826305, -0.0016027198, 0.0028376384, -0.014568444, -0.017999835, 0.0070344876, -0.0014601204, -0.0033066915 … 0.0022916698, 0.0036332316, 0.0008738122, 0.017492166, -0.0014709262, -0.0026239469, -0.0012154221, 0.002202745, -0.00089145737, 0.004507415]  
> Float32[0.0009504938, -0.005826305, -0.0016027198, 0.0028376384, -0.014568444, -0.017999835, 0.0070344876, -0.0014601204, -0.0033066915, 0.014370978 … 0.0036332316, 0.0008738122, 0.017492166, -0.0014709262, -0.0026239469, -0.0012154221, 0.002202745, -0.00089145737, 0.004507415, -0.0062177437]  
> ⋮

When I test the model against train\_data without optimisation, it works correctly.

> model.(train\_data)  
> 3440-element Vector{Vector{Float32}}:  
> [-0.00626456]  
> [-0.0066379453]  
> [0.0004110322]  
> [-0.0018467966]  
> [-0.0046000057]  
> [-0.0022317236]  
> [-0.0013433007]  
> [0.004694515]  
> [0.0062826206]  
> [0.0015981031]  
> [0.009047204]  
> [0.0074782283]  
> [0.0047134436]  
> ⋮
