<s> """<STR_LIT>""" <EOL> print ( __doc__ ) <EOL> import numpy as np <EOL> import matplotlib . pyplot as plt <EOL> from sklearn_theano . feature_extraction import fetch_overfeat_weights_and_biases <EOL> def make_visual ( layer_weights ) : <EOL> max_scale = layer_weights . max ( axis = - <NUM_LIT:1> ) . max ( axis = - <NUM_LIT:1> ) [ ... , <EOL> np . newaxis , np . newaxis ] <EOL> min_scale = layer_weights . min ( axis = - <NUM_LIT:1> ) . min ( axis = - <NUM_LIT:1> ) [ ... , <EOL> np . newaxis , np . newaxis ] <EOL> return ( <NUM_LIT:255> * ( layer_weights - min_scale ) / <EOL> ( max_scale - min_scale ) ) . astype ( '<STR_LIT>' ) <EOL> def make_mosaic ( layer_weights ) : <EOL> lw_shape = layer_weights . shape <EOL> lw = make_visual ( layer_weights ) . reshape ( <NUM_LIT:8> , <NUM_LIT:12> , * lw_shape [ <NUM_LIT:1> : ] ) <EOL> lw = lw . transpose ( <NUM_LIT:0> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:4> , <NUM_LIT:2> ) <EOL> lw = lw . reshape ( <NUM_LIT:8> * lw_shape [ - <NUM_LIT:1> ] , <NUM_LIT:12> * lw_shape [ - <NUM_LIT:2> ] , lw_shape [ <NUM_LIT:1> ] ) <EOL> return lw <EOL> def plot_filters ( layer_weights , title = None , show = False ) : <EOL> mosaic = make_mosaic ( layer_weights ) <EOL> plt . imshow ( mosaic , interpolation = '<STR_LIT>' ) <EOL> ax = plt . gca ( ) <EOL> ax . xaxis . set_visible ( False ) <EOL> ax . yaxis . set_visible ( False ) <EOL> if title is not None : <EOL> plt . title ( title ) <EOL> if show : <EOL> plt . show ( ) <EOL> weights , biases = fetch_overfeat_weights_and_biases ( large_network = True ) <EOL> plot_filters ( weights [ <NUM_LIT:0> ] ) <EOL> weights , biases = fetch_overfeat_weights_and_biases ( large_network = False ) <EOL> plt . figure ( ) <EOL> plot_filters ( weights [ <NUM_LIT:0> ] ) <EOL> plt . show ( ) </s>
