[英]CNN model for timeseries prediction
我想構建一個 CNN model。我有 x_train=8000000x7,y_train=8000000x2。 因為它是一個多元時間序列。 如何以 window 大小為 160 且步幅為 1 來提供輸入。
cnn model 的輸入應該是什么?
我使用 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]
對於 LSTM,我使用“輸入”作為輸入形狀。 CNN model 的輸入應該是什么。
1) CNN model 可以使用時間序列生成器嗎? 2) 是否有用於創建滑動 window 方法的數據生成器?
首先, TimeseriesGenerator
已被棄用,並且不將 tensorflow 張量作為輸入,因此我不鼓勵使用它。 相反,您可以使用 keras 實用程序中的timeseries_dataset_from_array
( 此處為文檔)。 它還生成滑動 windows。
對於時間序列預測,您應該使用一維 CNN。 他們將序列作為輸入,就像 LSTM 一樣。 至於形狀,在 Tensorflow 中仍然是:
input = data.shape[1], data.shape[2]
假設data.shape[0]
是批量大小, data.shape[1]
是序列長度, data.shape[2]
是每個元素的特征數。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.