import numpy as np
recording_length = 5000
n_features = 4
prediction_context = 10 # Change here
# The data you already have
X_data = np.random.random((recording_length, n_features))
to_predict = np.random.random((5000,1))
# Make lists of training examples
X_in = []
Y_out = []
# Append examples to the lists (input and expected output)
for i in range(recording_length - prediction_context):
X_in.append(X_data[i:i+prediction_context,:])
Y_out.append(to_predict[i+prediction_context])
# Convert them to numpy array
X_train = np.array(X_in)
Y_train = np.array(Y_out)
1 回答
你应该问自己的第一个问题是:
我们称之为时间刻度
prediction_context
.您现在可以创建数据集:
在末尾 :
X_train.shape = (recording_length - prediction_context, prediction_context, n_features)
因此,您需要在预测上下文的长度与培训网络所需的示例数量之间进行权衡 .