Last active
August 12, 2019 20:05
-
-
Save zckkte/d9fa6483d4d7f3bc9356776387e51bc8 to your computer and use it in GitHub Desktop.
Visualise activation in CNN
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from keras.models import Model | |
layer_outputs = [layer.output for layer in model.layers] | |
activation_model = Model(inputs=model.input, outputs=layer_outputs) | |
activations = activation_model.predict(X_train[10].reshape(1,28,28,1)) | |
def display_activation(activations, col_size, row_size, act_index): | |
activation = activations[act_index] | |
activation_index=0 | |
fig, ax = plt.subplots(row_size, col_size, figsize=(row_size*2.5,col_size*1.5)) | |
for row in range(0,row_size): | |
for col in range(0,col_size): | |
ax[row][col].imshow(activation[0, :, :, activation_index], cmap='gray') | |
activation_index += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment