Python API

Getting started with this project is easy. The main class you need to care about is subnet_plot.SubnetPlot

subnet_plot

subnet_plot defines the base objects and methods that enable component subplots to be combined, layered and animated with data from one or more sources.

Component subplots may be updated on a step or sub-step schedule, meaning that select subplots can display information at different rates or resolutions depending on their source data sets. Components are added to the parent plot in layers (defaults to a single layer), and each layer is updated sequentially.

See https://matplotlib.org/

class subnet_plot.SampleColumnPlot(plot_steps)

Sample column-prime composite plot with substep indexing

class subnet_plot.SampleRowPlot(plot_steps)

Sample row-prime composite plot with substep indexing

class subnet_plot.SubnetPlot(step_count, figure_size=None, gs_dim=4, gs_cols=1, gs_rows=1, pause_intervals=(0.25, 0.0001), substep_dim=1, window_title='Subnet Plot')

Define the parent figure which contains the plot and all subplot components

add_subplot(series_subplot, subplot_gspec, layer_idx=0)

Initialize the given subplot and add it to this plot at gspec

draw(step_idx)

Update all subplot components to display step_idx data points

update(step_idx)

Update each layer iteratively based on the step index

class subnet_plot.SubnetSubplot(series_arrays, subplot_axes, axis='on', grid=True, substep_dim=1, substep_idx=False, title=None, x_label=None, y_label=None, y_lim=True, y_line=None, y_log=False)

Base axes style, layout, and options for component subplots

add_legend(label_columns=None)

Add a legend to the upper right corner of this subplot

step_array(series_array, step_idx)

Return the selected array with the given indexing pattern

update(step_idx)

Update all dynamic elements in this subplot

class subnet_plot.SubplotBar(data_series_dict, subplot_axes, subplot_kwargs)

A bar subplot displaying elements with the assigned colormap

update(step_idx)

Update all dynamic elements in this subplot

class subnet_plot.SubplotLine(data_series_dict, subplot_axes, subplot_kwargs)

A line subplot with the ability to display bar plots in the background

update(step_idx)

Update all dynamic elements in this subplot

class subnet_plot.SubplotMatrix(data_series_dict, subplot_axes, subplot_kwargs)

An image subplot with optional left and top display axes

update(step_idx)

Update all dynamic components of this object

class subnet_plot.SubplotText(data_series_dict, subplot_axes, subplot_kwargs)

A text subplot including the primary table and optional row readouts

update(step_idx)

Update all row and column cell data for this subplot

subnet_plot.add_sample_bar_subplot(parent_plot, plot_gs, plot_steps, bar_count=25, layer_idx=0)

Add a sample bar subplot to parent_plot

subnet_plot.add_sample_line_subplot(parent_plot, plot_gs, plot_steps, layer_idx=0)

Add a sample line subplot to parent_plot

subnet_plot.add_sample_matrix_subplot(parent_plot, plot_gs, plot_steps, layer_idx=0)

Add a sample matrix subplot to parent_plot

subnet_plot.add_sample_text_subplot(parent_plot, plot_gs, plot_steps, layer_idx=0)

Add a sample text subplot to parent_plot

subnet_plot.bar_series(bar_array_dict, title, x_label, y_label, color_map='gnuplot_r', secondary_array_dict=None, substep_idx=False, y_line=None, y_log=False)

Return a bar plot data series of the form (data_dict, class, kwargs)

subnet_plot.color_map_list(value_max, cmap_id='gnuplot', value_min=0)

Return a list of color values from value_min to value_max

subnet_plot.display_plot(subnet_plot, static_plot=True)

Display, and optionally animate subnet_plot

subnet_plot.display_plot_static(subnet_plot)

Display the plot with data points drawn at its final index

subnet_plot.display_plot_steps(subnet_plot)

Iterate through step_count plot component updates

subnet_plot.display_sample_plots(plot_steps, static=True)

Display a series of sample plots and plot components

subnet_plot.line_bar_series(line_array_dict, title, x_label, y_label, bar_array_dict=None, color_map='viridis', substep_idx=False, x_limit=100, y_line=None, y_log=False)

Return a overlaid line plot of the form (data_dict, class, kwargs)

subnet_plot.line_series(line_array_dict, title, x_label, y_label, color_map='viridis', secondary_array_dict=None, secondary_color_map=None, substep_idx=False, x_limit=100, y_line=None, y_log=False)

Return a line plot data series of the form (data_dict, class, kwargs)

subnet_plot.matrix_series(matrix_array, title, center_color_map='plasma', left_array=None, left_color_map='magma', substep_idx=False, top_array=None, top_color_map='magma')

Return a matrix image series with optional left and top bar arrays

subnet_plot.text_series(text_table_dict, title, labels, substep_idx=False, text_col_dict=None)

Return a text plot data series of the form (data_dict, class, kwargs)

subnet_visualize

A Collection of data visualizations for neural networks implemented with the subnet_plot module. This module may be used as an example of ways to combine and animate the base components from subnet_plot.

class subnet_visualize.ActivationPlot(data_dict, layer_keys)

Each layer column contains feedback, activations and readout rows

class subnet_visualize.LayerPlot(data_dict, layer_keys, primary_key, selected_idx=0)

Display a 3 row plot with line, matrix, and bar rowplots

class subnet_visualize.LossPlot(data_dict, layer_key)

Display a 3 row plot with line, matrix, and bar rowplots

class subnet_visualize.NodePlot(data_dict, layer_key, selected_idx=0)

Display a 3 row plot with line, matrix, and bar rowplots

subnet_visualize.activation_readout_colplot(data_dict, layer_key, subnet_plot, subplot_spec)

Add a 3 rowed column activation plot to subnet_plot

subnet_visualize.bar_delta_overlaid_dicts(array_dict, primary_key, secondary_key, selected_idx, step_delta)

Return a bar graph with secondary_array overlaid with the primary_array

subnet_visualize.bar_overlaid_dicts(array_dict, primary_key, secondary_key)

Return an overlaid bar graph with input, activations and potentials

subnet_visualize.basic_stats_dict(data_dict, selected_idx)

Return the selected, min, max, mean of all data_dict array values

subnet_visualize.block_to_step_dict(block_steps, data_dict)

Convert all arrays from block-based arrays to step-based

subnet_visualize.input_delta_sum(data_dict, layer_key, input_keys)

Return the step-wise normalized delta input sum array

subnet_visualize.layer_activation_step_rowplot(data_dict, layer_keys, primary_key, selected_idx, subnet_plot, subplot_spec)

Return a plot containing activation and potential line subplots

subnet_visualize.layer_image_readout_colplot(data_dict, layer_key, selected_idx, subnet_plot, subplot_spec)

Return a plot containing input, weight and step subplots

subnet_visualize.layer_weight_step_colplot(data_dict, layer_key, subnet_plot, subplot_spec)

Return a 2-row column plot containing weight matrix and input plots

subnet_visualize.line_dict(array_dict, array_key, selected_idx=0)

Return a dictionary of lines and a step segmentation dict

subnet_visualize.line_mean_dict(array_dict, primary_key, mean_line=True, selected_idx=0)

Return a dictionary of lines and a step segmentation dict

subnet_visualize.line_weight_delta_dict(array_dict, array_keys, array_subkey, delta_steps=50)

Calculate the difference between array_subkey offset by block_steps

subnet_visualize.node_input_block_rowplot(data_dict, focus_key, subnet_plot, subplot_spec, selected_idx)

Return a plot containing input, weight and step subplots

subnet_visualize.node_potential_block_rowplot(data_dict, focus_key, subnet_plot, subplot_spec, selected_idx)

Return a plot containing activation and potential line subplots

subnet_visualize.node_weight_block_rowplot(data_dict, focus_key, subnet_plot, subplot_spec, selected_idx, step_delta=50)

Return a plot containing a single weight subplot for the selected index

subnet_visualize.ooc_target_array(data_dict)

Return a mask array with single out-of-class target selections

subnet_visualize.sample_seg_array(array_steps, block_steps)

Return a binary segmentation array

subnet_visualize.sample_sigma_arrays(data_dict)

Return the in-class and mean gain arrays

subnet_visualize.segmentation_dict(array_dict, segment_steps)

Return a segmented array of array_steps length with matching dimensions

subnet_visualize.table_row_readout_dicts(data_dict, focus_key, selected_idx)

Return the text dictionary and column labels for the text subplot

subnet_visualize.visualize_data(data_dict, plot_type, selected_idx, selected_key, static_plot=False)

Visualize all elements in data_dict in a single combined plot

subnet_visualize.weight_matrix_arrays(data_dict)

Return the weight matrix and arrays for the matrix subplot

subnet_animate

Display matplotlib based animations from neural network data