【发布时间】:2017-10-14 18:15:01
【问题描述】:
对不起,我是 RNN 的新手。我在 TimeDistributed 层上阅读了this post。
我已将我的数据重构为 Keras 所需的 [samples, time_steps, features]:[140*50*19],这意味着我有 140 个数据点,每个数据点有 50 个时间步长和 19 个特征。我的输出形状为[140*50*1]。我更关心最后一个数据点的准确性。这是一个回归问题。
我当前的代码是:
x = Input((None, X_train.shape[-1]) , name='input')
lstm_kwargs = { 'dropout_W': 0.25, 'return_sequences': True, 'consume_less': 'gpu'}
lstm1 = LSTM(64, name='lstm1', **lstm_kwargs)(x)
output = Dense(1, activation='relu', name='output')(lstm1)
model = Model(input=x, output=output)
sgd = SGD(lr=0.00006, momentum=0.8, decay=0, nesterov=False)
optimizer = sgd
model.compile(optimizer=optimizer, loss='mean_squared_error')
我的问题是:
- 我的情况是多对多的,所以我需要使用
return_sequences=True?如果我只需要最后一个时间步的预测,那将是多对一的。所以我需要我的输出是[140*1*1]和return_sequences=False? - 如果我使用多对多,有什么方法可以提高我最后时间点的准确性吗?我更关心它而不是其他点的准确性。
-
我尝试使用 TimeDistributed 层作为
output = TimeDistributed(Dense(1, activation='relu'), name='output')(lstm1)性能似乎比不使用 TimeDistributed 层要差。为什么会这样?
- 我尝试使用
optimizer=RMSprop(lr=0.001)。我认为RMSprop应该稳定神经网络。但是我使用RMSprop从来没有得到好的结果。 - 如何选择好的
lr和SGD的动量?我一直在手动测试不同的组合。 keras中有交叉验证方法吗?
【问题讨论】:
-
你为什么写
[140*50*19]而不是[140, 50, 19]?形状真的是[133000]吗? -
谢谢,我的意思是 [140, 50, 19]
标签: python neural-network keras lstm keras-layer