This is probably a pretty simple error on my end, but I cannot seem to figure it out. I'm trying to build an RNN that will learn numeric sequences. Example dataset (each row represents a data point)
0 0 0 1 3
0 0 0 0 0
0 0 1 3 0
...
I'm mainly following this example: https://www.juliabloggers.com/a-basic-rnn/
My data and the data in the examples are read as Array{Array{Float64,1},1}. Here is some of my code
function eval_model(model, x)
out = model.(x)[end]
Flux.reset!(model)
return out
end
m = Chain(GRU(1, 40), Dense(40, 1, σ))
loss(y) = Flux.crossentropy(eval_model(m, y), y)
ps = Flux.params(m)
opt = Flux.ADAM()
@epochs 100 Flux.train!(loss, ps, data, opt)
Output:
MethodError: no method matching loss(::Float64, ::Float64, ::Float64, ::Float64, ::Float64)
Closest candidates are:
loss(::Any, ::Any) at In[4]:2
The loss function is reading each number in a sequence as an individual input to the loss function (I've tried other sequence lengths, and the error is the same but it's "MethodError: no method matching loss((length of sequence) * ::Float64)".
In the example that I'm working off of, this isn't an issue. I could build the training procedure from scratch, but would rather pass things to Flux.