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]
⋮