Al *_*irk 6 python time-series feature-extraction conv-neural-network keras
我正在尝试从我的 1D CNN 中提取特征重要性。大多数在线文档都涉及 2D、3D、图像数据和分类问题。我有一个输出时间序列序列的多元时间序列。我尝试过 Shaply 和 keras_vis,但没有解决我的问题。一个问题是我的输入数据有 229 个特征,1DConv 的第一层映射了 64 个过滤器。从第一层提取权重,我可以确定哪个过滤器有助于该层的学习。但是,我无法将其转换为原始输出。
我的问题是双重的(如果我能同时做到):
这是用于提取权重的摘要和代码....
Model: "model_3"
__________________________________________________________________________________________________
Layer (type) Output Shape Param # Connected to
==================================================================================================
CNN1-Input-Historical (InputLay [(None, 10, 229)] 0
__________________________________________________________________________________________________
CNN1-Conv1D (Conv1D) (None, 7, 64) 58688 CNN1-Input-Historical[0][0]
__________________________________________________________________________________________________
conv1d_3 (Conv1D) (None, 3, 128) 24704 CNN1-Conv1D[0][0]
__________________________________________________________________________________________________
CNN1-MaxPooling (MaxPooling1D) (None, 2, 128) 0 conv1d_3[0][0]
__________________________________________________________________________________________________
CNN1-Flatten (Flatten) (None, 256) 0 CNN1-MaxPooling[0][0]
__________________________________________________________________________________________________
dense_9 (Dense) (None, 50) 12850 CNN1-Flatten[0][0]
__________________________________________________________________________________________________
dense_10 (Dense) (None, 50) 2550 dense_9[0][0]
__________________________________________________________________________________________________
dropout_6 (Dropout) (None, 50) 0 dense_10[0][0]
__________________________________________________________________________________________________
dense_11 (Dense) (None, 100) 5100 dropout_6[0][0]
__________________________________________________________________________________________________
dropout_7 (Dropout) (None, 100) 0 dense_11[0][0]
__________________________________________________________________________________________________
Output-1 (Dense) (None, 3) 303 dropout_7[0][0]
__________________________________________________________________________________________________
Output-2 (Dense) (None, 3) 303 dropout_7[0][0]
__________________________________________________________________________________________________
Output-3 (Dense) (None, 3) 303 dropout_7[0][0]
==================================================================================================
Total params: 104,801
Trainable params: 104,801
Non-trainable params: 0
Run Code Online (Sandbox Code Playgroud)
model.summary()
outputs = [layer.output for layer in model.layers[1:]]
activation_model = Model(inputs=model.input, outputs=outputs)
activations = activation_model.predict(X.reshape(1,10,229))#3-d 10 timesteps and 229 featrues
first_layer_activation = activations[0]
second_layer_activation = activations[1]
Run Code Online (Sandbox Code Playgroud)