Open reshadshuvo123 opened 6 years ago
I want to visualize features the last layer of CNN for MNIST dataset using stitching that used in Activation Maximization on VGGNet (Keras-vis)
`from vis.visualization import get_num_filters layer_name = 'dense_2' # my last layer mnist layer_idx = utils.find_layer_idx(model, layer_name)
filters = np.arange(get_num_filters(model.layers[layer_idx]))
vis_images = [] for idx in filters: img = visualize_activation(model, layer_idx, filter_indices=idx)
# Utility to overlay text on image. vis_images.append(img)
stitched = utils.stitch_images(vis_images, cols=5) plt.axis('off') plt.imshow(stitched) plt.title(layer_name) plt.show()`
But I got error message
**ValueError: could not broadcast input array from shape (28,28) into shape (28,28,1)
Can you please suggest me how can I display similar result for MNIST dataset?
I want to visualize features the last layer of CNN for MNIST dataset using stitching that used in Activation Maximization on VGGNet (Keras-vis)
`from vis.visualization import get_num_filters layer_name = 'dense_2' # my last layer mnist
layer_idx = utils.find_layer_idx(model, layer_name)
filters = np.arange(get_num_filters(model.layers[layer_idx]))
Generate input image for each filter.
vis_images = [] for idx in filters: img = visualize_activation(model, layer_idx, filter_indices=idx)
Generate stitched image palette with 5 cols.
stitched = utils.stitch_images(vis_images, cols=5)
plt.axis('off') plt.imshow(stitched) plt.title(layer_name) plt.show()`
But I got error message
**ValueError: could not broadcast input array from shape (28,28) into shape (28,28,1)
Can you please suggest me how can I display similar result for MNIST dataset?