I am mimicking the code from this page, implenting LSTM to predict time series behaviour. I use R
so I just translated the content and adapted it to my dataset using R keras
package.
So, here it goes, I have
train_input
is a vector of random numbers between 8 and 21, let's say [9,10,19,17,...]. train_output
is the shifted train_input
vector by a one step : [10,19,17,...].
model <- keras_model_sequential()
model %>% layer_lstm(model,4,input_shape=c(1,1)%>% layer_dense(1)
model %>%compile(loss="mean_squared_error",optimizer="adam")
model %>% fit(train_input,train_output)
model %>% predict(test)
Here's I formatted the train_input
in the expected 3D
format ,by doing
train_input <- array(train_input,dim=c(length(train_input),1,1))
Now, when I run mod%>% predict(test)
for a test vector I get incoherent numbers between 0
and 1
, as if probabilities have been computed. Do someone have an explanation ?