def plot_sequence_filters(dnn): fig = plt.figure(figsize=(15, 8)) fig.subplots_adjust(hspace=0.1, wspace=0.1) conv_filters = dnn.get_sequence_filters() num_plots_per_axis = int(len(conv_filters)**0.5) + 1 for i, conv_filter in enumerate(conv_filters): ax = fig.add_subplot(num_plots_per_axis, num_plots_per_axis, i + 1) add_letters_to_axis(ax, conv_filter.T) ax.axis("off") ax.set_title("Filter %s" % (str(i + 1)))
def plot_sequence_filters(dnn): fig = plt.figure(figsize=(15, 8)) fig.subplots_adjust(hspace=0.1, wspace=0.1) conv_filters = dnn.get_sequence_filters() num_plots_per_axis = int(len(conv_filters)**0.5) + 1 for i, conv_filter in enumerate(conv_filters): ax = fig.add_subplot(num_plots_per_axis, num_plots_per_axis, i+1) add_letters_to_axis(ax, conv_filter.T) ax.axis("off") ax.set_title("Filter %s" % (str(i+1)))
def plot_sequence_filters(model): fig = plt.figure(figsize=(15, 8)) fig.subplots_adjust(hspace=0.1, wspace=0.1) conv_filters = model.layers[0].get_weights()[0] #transpose for plotting conv_filters = np.transpose(conv_filters, (3, 1, 2, 0)).squeeze(axis=-1) num_plots_per_axis = int(len(conv_filters)**0.5) + 1 for i, conv_filter in enumerate(conv_filters): ax = fig.add_subplot(num_plots_per_axis, num_plots_per_axis, i + 1) add_letters_to_axis(ax, conv_filter) ax.axis("off") ax.set_title("Filter %s" % (str(i + 1)))
def plot_sequence_filters(model): fig = plt.figure(figsize=(15, 8)) fig.subplots_adjust(hspace=0.1, wspace=0.1) conv_filters=model.layers[0].get_weights()[0] #transpose for plotting conv_filters=np.transpose(conv_filters,(3,1,2,0)).squeeze(axis=-1) num_plots_per_axis = int(len(conv_filters)**0.5) + 1 for i, conv_filter in enumerate(conv_filters): ax = fig.add_subplot(num_plots_per_axis, num_plots_per_axis, i+1) add_letters_to_axis(ax, conv_filter) ax.axis("off") ax.set_title("Filter %s" % (str(i+1)))
def plot_sequence_filters(model, prefix): ''' model - a trained SequenceDNN prefix - the name of the loaded model ''' fig = plt.figure(figsize=(15, 8)) fig.subplots_adjust(hspace=0.1, wspace=0.1) conv_filters = model.get_sequence_filters() num_plots_per_axis = int(len(conv_filters)**0.5) + 1 for i, conv_filter in enumerate(conv_filters): ax = fig.add_subplot(num_plots_per_axis, num_plots_per_axis, i + 1) add_letters_to_axis(ax, conv_filter.T) ax.axis('off') ax.set_title('Filter %s' % (str(i + 1))) fig.savefig('{}_convolutional_filters.png'.format(prefix), bbox_inches='tight')