@@ -0,0 +1,1263 @@
+from pathlib import Path%0A%0Afrom keras.applications import VGG16%0Afrom keras.models import Model%0Aimport matplotlib.pyplot as plt%0Afrom mpl_toolkits.axes_grid1 import AxesGrid%0A%0Afrom tools.datasets.urban_tribes import load_images%0A%0A%0Adef plot_filter(image_path, layer_name, output_dir):%0A    base_model = VGG16(weights='imagenet')%0A    x = load_images(%5Bimage_path%5D)%0A    model = Model(input=base_model.input,%0A                  output=base_model.get_layer(layer_name).output)%0A    layer_output = model.predict(x)%0A%0A    fig = plt.figure(figsize=(12, 12))%0A%0A    grid = AxesGrid(fig, 111,%0A                    nrows_ncols=(8, 8),%0A                    axes_pad=0.0,%0A                    share_all=True,%0A                    label_mode=%22L%22,%0A                    cbar_location=%22top%22,%0A                    cbar_mode=%22single%22)%0A%0A    for i in range(64):%0A        im = grid%5Bi%5D.imshow(layer_output%5B0, :, :, i%5D, interpolation=%22nearest%22)%0A    grid.cbar_axes%5B0%5D.colorbar(im)%0A%0A    for cax in grid.cbar_axes:%0A        cax.toggle_label(False)%0A%0A    for ax in grid.axes_all:%0A        ax.get_xaxis().set_visible(False)%0A        ax.get_yaxis().set_visible(False)%0A%0A    output_dir = Path(output_dir)%0A    fig_file = '%7B%7D-%7B%7D.pdf'.format(Path(image_path).stem, layer_name)%0A    plt.savefig(str(output_dir / fig_file))%0A

Add a convenient function to plot filter