简体   繁体   English

CNN model 用于时间序列预测

[英]CNN model for timeseries prediction

I want to build a CNN model. I have x_train=8000000x7, y_train=8000000x2.我想构建一个 CNN model。我有 x_train=8000000x7,y_train=8000000x2。 Since it is a multivariant time series.因为它是一个多元时间序列。 How can feed the input with window size of 160 and stride=1.如何以 window 大小为 160 且步幅为 1 来提供输入。

what should be the input for cnn model? cnn model 的输入应该是什么?

I used timeseriesgenerator for creating a dataset as follows我使用 timeseriesgenerator 创建数据集如下

train_gen = tf.keras.preprocessing.sequence.TimeseriesGenerator(X_train, Y_train,
                                                                length=160, sampling_rate=1,shuffle=False, batch_size=256)


batch_0  = train_gen[0]
data, label = batch_0
print("Shape of the generator data and label:", data.shape, label.shape)

input=data.shape[1],data.shape[2]

For LSTM I have used 'input' as the input shape.对于 LSTM,我使用“输入”作为输入形状。 What should be the input for CNN model. CNN model 的输入应该是什么。

1)can use timeseriesgeneartor for CNN model? 1) CNN model 可以使用时间序列生成器吗? 2) is there any datagenerator for creating a sliding window approach? 2) 是否有用于创建滑动 window 方法的数据生成器?

First, TimeseriesGenerator is deprecated and do not take tensorflow tensor as input so I discourage to use it.首先, TimeseriesGenerator已被弃用,并且不将 tensorflow 张量作为输入,因此我不鼓励使用它。 Instead you can use timeseries_dataset_from_array (doc here ) from keras utils.相反,您可以使用 keras 实用程序中的timeseries_dataset_from_array此处为文档)。 It also generate sliding windows.它还生成滑动 windows。

For time serie prediction, you should use 1-D CNN.对于时间序列预测,您应该使用一维 CNN。 They take a sequence as input exactly like LSTM.他们将序列作为输入,就像 LSTM 一样。 As shape is concerned, in Tensorflow it is still:至于形状,在 Tensorflow 中仍然是:

input = data.shape[1], data.shape[2]

Assuming that data.shape[0] is the batch size, data.shape[1] the sequence length and data.shape[2] the number of features of each elements.假设data.shape[0]是批量大小, data.shape[1]是序列长度, data.shape[2]是每个元素的特征数。

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

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