我有两个时间序列A和B:
A: 1,2,3,1,2,3,3,3,1,2,3,3,3
B: 0,0,1,0,0,1,1,1,0,0,1,1,1这个简单的训练集表示信号B与A相关,事实上每次A等于3,在同一时间标记,在B中,值是1。
为了解释我的问题,我介绍了上面的例子。当我使用带有Keras的LSTM来预测数据时,我希望模型从序列中了解这种依赖关系。
现在我使用这个配置:
model.add(keras.layers.LSTM(hidden_nodes, activation='sigmoid', input_dim=num_features, input_length=window, consume_less="mem"))
model.add(keras.layers.Dense(num_features, activation='sigmoid'))
optimizer = keras.optimizers.SGD(lr=learning_rate, decay=1e-6, momentum=0.9, nesterov=True)但我看到,LSTM的预测值显然没有使用时间序列之间的依赖关系。如果我用一个窗口5进行预测,为了预测下一个点:
A: [1,2,3,1,2]
B: [0,0,1,0,0]我希望LSTM给出A的值3,B的值1,因为下面的训练设置是这样的。
问题是,我的网络似乎使用信号,而不给信号依赖赋予正确的权重。
发布于 2017-10-19 13:12:33
您应该只有一个系列,有两个功能。
如果A和B是列表(不是numpy数组):
fullSeq = np.array(A + B)
#this shape is (lenA + lenB,)
fullSeq = fullSeq.reshape((2,len(A)))
fullSeq = fullSeq.swapaxes(0,1).reshape((1,len(A),2))
#make sure that the resulting array is something like [[[1,0],[2,0],[3,1],...]]现在,您有了num_features=2的一个序列。A和B现在完全依赖。
https://stackoverflow.com/questions/46818865
复制相似问题