简体   繁体   English

多次安装 Keras-LSTM model

[英]Fit a Keras-LSTM model multiple times

Problem description:问题描述:

Given a set X of 100 time series train/fit a Keras-LSTM model with 70/100 time series,generate 30 predictions and compare them to the 30 remaining time series of X.给定一组 100 个时间序列的 X 训练/拟合具有 70/100 时间序列的 Keras-LSTM model,生成 30 个预测并将它们与 X 的剩余 30 个时间序列进行比较。

Approach in pseudocode:伪代码方法:

    lookBack = 3
    for i in range(0, 70):
        xData, YData = sample(timeSeries[i], lookBack)
        model.fit(xData, yData)
        
    for i in range(70, len(timeSeries)):
        xData, _ = sample(timeSeries[i], lookBack)
        model.predict(xData)

I was wondering if my approach would work as I don't know if consecutive calls to.fit() work.我想知道我的方法是否可行,因为我不知道连续调用 to.fit() 是否有效。 Does the model reset its state in each iteration? model 是否在每次迭代中重置其 state?

It seems that this was already answered here but I don't know if this is still relevant as it was way back in 2016.似乎这已经在这里得到了回答,但我不知道这是否仍然相关,因为它早在 2016 年。

Furthermore is there an alternative way to do this?此外,还有其他方法可以做到这一点吗?

My assignment focuses strongly on the tuning of the hyperparameters (total-layers,type-of-layers,neurons/layer, epoch and batch-size ) and not so much at the implementation itself.我的任务主要集中在超参数的调整(总层、层类型、神经元/层、时期批量大小),而不是实现本身。 I was thinking of using fit with generators as it is indicated in the documentation but I have no clue on how to design one and even if I did I don't know if this allows the tuning of the hyperparameters我正在考虑将 fit 与生成器一起使用,因为它在文档中有所说明,但我不知道如何设计一个,即使我这样做了,我也不知道这是否允许调整超参数

Yes you can call Fit method multiple times.是的,您可以多次调用 Fit 方法。

Yes, successive calls to fit will incrementally train the model.

Commented by @fchollet.由@fchollet 评论。 https://github.com/keras-team/keras/issues/4446#issuecomment-261804574 https://github.com/keras-team/keras/issues/4446#issuecomment-261804574

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM