Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何利用卷积神经网络对时间序列数据进行建模_Python_Neural Network_Time Series_Lstm - Fatal编程技术网

Python 如何利用卷积神经网络对时间序列数据进行建模

Python 如何利用卷积神经网络对时间序列数据进行建模,python,neural-network,time-series,lstm,Python,Neural Network,Time Series,Lstm,我有一个2d矩阵,行代表不同的价格水平,列代表最后的N条。 例如,二维矩阵看起来像: Price Bar0 Bar1 Bar2 Bar3 Bar4 Bar5 ... 0 0 0 1 1 0 0 1 1 0 1 1 0 1 2 1 1 1 1 1 1 3 1

我有一个2d矩阵,行代表不同的价格水平,列代表最后的N条。 例如,二维矩阵看起来像:

Price   Bar0   Bar1   Bar2   Bar3   Bar4   Bar5  ...
0         0     0      1      1       0     0
1         1     0      1      1       0     1
2         1     1      1      1       1     1
3         1     1      0      1       1     0
4         0     0      0      0       1     0
...
该矩阵将表示以下各项的价格数据:

       High    Low
Bar0    3       1
Bar1    3       2
Bar2    2       0
Bar3    3       0
Bar4    4       2
Bar5    2       1
在传递给LSTM进行监督学习之前,我想使用卷积神经网络进行特征提取。应该有其他指标,如移动平均数,也传递给LSTM进行学习

# LSTM and CNN for sequence classification in the IMDB dataset

import numpy
from keras.datasets import imdb
from keras.models import Sequential
from keras.layers import Dense
from keras.layers import LSTM

from keras.layers.convolutional import Conv1D

from keras.layers.convolutional import MaxPooling1D

from keras.layers.embeddings import Embedding
from keras.preprocessing import sequence
# fix random seed for reproducibility
numpy.random.seed(7)
# load the dataset but only keep the top n words, zero the rest
top_words = 5000
(X_train, y_train), (X_test, y_test) = imdb.load_data(num_words=top_words)
# truncate and pad input sequences
max_review_length = 500
X_train = sequence.pad_sequences(X_train, maxlen=max_review_length)
X_test = sequence.pad_sequences(X_test, maxlen=max_review_length)
# create the model
embedding_vecor_length = 32
model = Sequential()
model.add(Embedding(top_words, embedding_vecor_length,    input_length=max_review_length))
model.add(Conv1D(filters=32, kernel_size=3, padding='same', activation='relu'))
model.add(MaxPooling1D(pool_size=2))
model.add(LSTM(100))
model.add(Dense(1, activation='sigmoid'))

model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])

我已经读过上面序列分类的代码,我正在尝试适应时间序列。请帮助。

我找到了一个很棒的软件包,可以搜索时间序列建模的最佳体系结构: GitHub.com/NLeSC/mcfly

它提供了适合我的目的的DeepConvLSTM模型