Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python LSTM keras封装非相干输出_Python_R_Tensorflow_Keras_Lstm - Fatal编程技术网

Python LSTM keras封装非相干输出

Python LSTM keras封装非相干输出,python,r,tensorflow,keras,lstm,Python,R,Tensorflow,Keras,Lstm,我模仿了这段代码,使用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)%>% l

我模仿了这段代码,使用LSTM来预测时间序列行为。我使用了
R
,所以我只是翻译了内容,并使用R
keras
包将其改编为我的数据集

好了,我有

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)

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

你应该有一个额外的密集层作为网络的输出,而不是
LSTM
,并尝试使用激活功能
'linear'
@djk47463抱歉,我在写这篇文章时有一个打字错误,我确实有这个
密集层(1)
。这就是你的意思吗?是的,你能补充一下吗it@djk47463我就是这么做的,但它什么也没改变。你把输入数据规范化了吗?
train_input <- array(train_input,dim=c(length(train_input),1,1))