我有一个由不同长度的时间序列组成的数据集。例如,考虑一下这个ts1 = np.random.rand(230, 4)
ts2 = np.random.rand(12309, 4)
我有200个数组列表形式的序列
^{pr2}$
如果良好,这些时间序列的标签为1,否则为0。因此我的标签应该是labels = [0, 0, 1, 0, 1, ....]
我正在构建一个keras模型,如下所示:model = keras.Sequential([
keras.layers.Conv1D(64, 3, activation='relu', input_shape=(None, 4)),
keras.layers.MaxPool1D(3),
keras.layers.Conv1D(160, 10, activation='relu'),
keras.layers.GlobalAveragePooling1D(),
keras.layers.Dropout(0.5),
keras.layers.Dense(128, activation='relu'),
keras.layers.Dense(2, activation='softmax')
]))
第一个卷积层的输入形状中的4对应于每个时间序列中的列数,该列数是恒定的(可以认为它有4个传感器返回不同操作的测量值)。目标是分类一个时间序列是好是坏(0或1),但是我不知道如何使用keras来训练它。在
跑这条线model.fit(input_x, labels, epochs=5, batch_size=1)
返回错误Error when checking model input: the list of Numpy arrays that you are passing to your model is not the size the model expected. Expected to see 1 array(s), but instead got the following list of 200 arrays
甚至使用np.数组(input_x)给出一个错误。如何用可变长度的序列训练这个模型?我知道填充是一种选择,但那不是我想要的。另外,我不想使用带有滑动窗口的RNN。我真的在寻找一个解决方案与1dcnn工作的可变长度序列。任何帮助都将不胜感激!在