I’m trying to get an RNN to work with timeseries and I don’t understand why things don’t work as expected. I found a workaround, but it just seems to be too complicated.
My data are sequences of 29 observations, and I have 210 observations. With the
chunk function I got the
(29x210) matrix reshaped into a 210-element Array
X = reshape(rand(29*210), (29,210)
train_x = chunk(X, 210)
To get my
y in the same shape, I apply
chunk there as well:
y = chunk(rand(210), 210)
I created an RNN model
rnn() = Chain(RNN(29,10), Dense(10,1)) that returns a single value. I can now run this as
yhat = m.(train_x)
This outputs a 210-element Array. So far, so good, I think. Now I’m trying to create a MAE loss function. So,
yhat .- y works as expected (where I can even ommit the dot). Now I’m trying to apply the
abs function. I can understand why
abs(yhat .- y) does not work, but I would have expected
abs.(yhat.-y) to work. Which it does not…
Well, I can flatten the difference with
..., but that leaves me with
abs.([((yhat .- y)...)...]) with is both ugly and unreadable. I’m guessing I’m doing something wrong here, but I dont understand why
abs.(yhat.-y) does not work as expected.
Also, I will want to feed this to
train! eventually, and I’m not a 100% sure that all these dots will work as expected with the gradients.
- can someone explain why abs.(yhat .- y) does not work as expected?
- What is the advised way to approach this? Is this approach with all the
...indeed what is necessary, or is there a more elegant way?