我目前正在使用一维卷积神经网络对 Keras 中的多元时间序列进行分类。特别是,每个实例由 9 个等长时间序列(每个 300 个点)表示。
正如我在文献中所读到的,当在图像上使用 2D 卷积时,可以获得关于网络正在寻找的位置以进行分类的提示:例如,您可以使用所谓的类激活图,例如:
https://rajpurkar.github.io/mlx/visualizing-cnns/class_activation_maps.png
有什么类似的东西可以用来可视化给定多元时间序列中最“有意义”的切片吗?
这是我当前的网络架构:
Input shape: 300 9
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
conv1d_1 (Conv1D) (None, 292, 128) 10496
_________________________________________________________________
batch_normalization_1 (Batch (None, 292, 128) 512
_________________________________________________________________
activation_1 (Activation) (None, 292, 128) 0
_________________________________________________________________
max_pooling1d_1 (MaxPooling1 (None, 58, 128) 0
_________________________________________________________________
conv1d_2 (Conv1D) (None, 50, 128) 147584
_________________________________________________________________
batch_normalization_2 (Batch (None, 50, 128) 512
_________________________________________________________________
activation_2 (Activation) (None, 50, 128) 0
_________________________________________________________________
max_pooling1d_2 (MaxPooling1 (None, 10, 128) 0
_________________________________________________________________
flatten_1 (Flatten) (None, 1280) 0
_________________________________________________________________
dense_1 (Dense) (None, 300) 384300
=================================================================
Total params: 543,404
Trainable params: 542,892
Non-trainable params: 512
_________________________________________________________________
就目前而言,我已经成功地可视化了网络中的激活函数。例如,下面的代码片段在给定输入实例的情况下打印第一个激活层中第一个激活函数(第一个超过 128)的结果:
from keras import models
layer_outputs = [layer.output for layer in model.layers[:2]]
activation_model = models.Model(inputs=model.input, outputs=layer_outputs)
activations = activation_model.predict(X_train_windows[0:1])
first_layer_activation = activations[0]
print(first_layer_activation.shape)
plt.plot(first_layer_activation[0, :, 0])
结果是以下时间序列,长度为 292:
https://i.ibb.co/TqK6g9D/Schermata-2019-01-15-alle-10-24-39-2.png
但是,我发现很难直观地解释图表。
我怎样才能为这样的时间序列赋予意义?有没有办法像在 CAM 中那样突出显示输入?
谢谢!