LSTM keras包非相干输出

2024-09-29 23:20:20 发布

您现在位置:Python中文网/ 问答频道 /正文

我在模仿这个page中的代码,使用LSTM来预测时间序列行为。我使用R,所以我只是翻译了内容,并使用Rkeras包将其改编为我的数据集。你知道吗

所以,就这样,我有了

train_input是8到21之间的随机数向量,比如说[9,10,19,17,…]。train_output是经过一步移位的train_input向量:[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)

下面是我用期望的3D格式格式化train_input,方法是

train_input <- array(train_input,dim=c(length(train_input),1,1))

现在,当我对一个测试向量运行mod%>% predict(test)时,我得到了01之间的非相干数,就好像概率已经被计算过一样。有人解释吗?你知道吗


Tags: 代码testlayer内容inputoutputmodel时间

热门问题