visualization package

visualization.alpha_deltaT

Run as:

python visualization/alpha_deltaT.py wandb.project=”cifar10 optuna multiseed” dataset=CIFAR10

visualization.alpha_deltaT.alpha_deltaT_plot(df: pandas.core.frame.DataFrame, dataset: str = 'CIFAR10', init_ll: List[str] = ['ERK', 'Random'], density_ll: List[float] = [0.1, 0.2, 0.5])

Plot contour plot depicting alpha-deltaT trial space

Parameters
  • df (pd.DataFrame) – Dataframe containing main results

  • dataset (str) – dataset to plot

  • init_ll (List[str]) – List of initialization schemes to plot

  • density_ll (List[float]) – List of densities to plot

visualization.alpha_deltaT.get_stats(runs, reorder: bool = True) → pandas.core.frame.DataFrame

Get stats saved on W&B.

List all possible choices for (masking, init, density, dataset). We’ll try matching the exhaustive caretesian product.

Parameters
  • runs (wandb.api.runs) – Experiment run

  • reorder (bool) – sort methods alphabetically

Returns

Dataframe containing test accuracies of methods

Return type

pd.DataFrame

visualization.alpha_deltaT.main(cfg: omegaconf.dictconfig.DictConfig)

visualization.density_distribution

python sparselearning/visualization/lr_tuning.py wandb.project=”cifar10 grid lr” dataset=CIFAR10

visualization.erk_vs_random_FLOPs

Run as: python visualization/erk_vs_random_FLOPs.py

visualization.erk_vs_random_FLOPs.FLOPs_vs_sparsity(model: str = 'wrn-22-2')

FLOPs vs sparsity for Random, ERK initializations :param model: model name (wrn-22-2, resnet50) to use. :type model: str

visualization.erk_vs_random_FLOPs.accuracy_vs_FLOPs()

Plot test accuracy vs FLOPs for ERK, Random init

visualization.lr_tuning

Run as:

python visualization/lr_tuning.py wandb.project=”cifar10 grid lr” dataset=CIFAR10

visualization.lr_tuning.get_stats(runs, masking_ll: List[str] = ['RigL'], init_ll: List[str] = ['Random'], suffix_ll: List[str] = ['grid_lr'], density_ll: List[float] = [0.1], lr_ll: List[float] = [0.1], alpha_ll: List[float] = [0.3], deltaT_ll: List[float] = [100], dataset_ll: List[str] = ['CIFAR10'], reorder: bool = True) → pandas.core.frame.DataFrame

Get stats saved on W&B.

List all possible choices for (masking, init, density, dataset).

We’ll try matching the exhaustive caretesian product of (masking_ll x init_ll x suffix_ll x density_ll etc).

Parameters
  • runs (wandb.api.runs) – Experiment run

  • masking_ll (List[str]) – List of sparse training techniques

  • init_ll (List[str]) – List of sparsity initialization schemes

  • suffix_ll (List[str]) – List of method suffixes.

  • density_ll (List[float]) – List of density values (1 - sparsity)

  • lr_ll (List[float]) – List of learning rates

  • alpha_ll (List[float]) – List of alphas (initial pruning rate)

  • deltaT_ll (List[float]) – List of deltaT’s to plot

  • dataset_ll (List[str]) – List of datasets

  • reorder (bool) – sort methods alphabetically

Returns

Dataframe containing test accuracies of methods

Return type

pd.DataFrame

visualization.lr_tuning.lr_tuning_plot(df: pandas.core.frame.DataFrame, dataset: str = 'CIFAR10', init_ll: List[str] = ['ERK', 'Random'], density_ll=[0.1, 0.2, 0.5], lr_ll: List[float] = [0.1], alpha_ll: List[float] = [0.3], deltaT_ll: List[float] = [100])

Plot LR tuning trials

Parameters
  • df (pd.DataFrame) – Dataframe containing main results

  • dataset (str) – dataset to plot

  • init_ll (List[str]) – List of initialization schemes to plot

  • density_ll (List[float]) – List of densities to plot

  • lr_ll (List[float]) – List of learning rates

  • alpha_ll (List[float]) – List of alphas (initial pruning rate)

  • deltaT_ll (List[float]) – List of deltaT’s to plot

visualization.lr_tuning.main(cfg: omegaconf.dictconfig.DictConfig)

visualization.main_plots

visualization.main_plots.cifar100plots()

Create plots for the CIFAR100 dataset (Figs. 2a and 2b).

visualization.main_plots.cifar10plots()

Create plots for the CIFAR10 dataset (Figs. 1a, 1b and 1c).

visualization.main_plots.create_plot_from_spec(data, plot_spec, ylimits, name)

Create and save a plot using the data based on plot_spec.

The plot_spec is list of tuples with each tuple corresponding to one plot of accuracy vs density. The tuple should have three entries - the method, the initialization scheme, and the color of the plot.

Parameters
  • data – Pandas DataFrame containing data about runs

  • plot_spec – List of tuples (<method>, <init_scheme>, <color_of_line>)

  • ylimits – y limits of the plot

  • name – Name of save file

visualization.main_plots.main(cfg: omegaconf.dictconfig.DictConfig)
visualization.main_plots.plot_col_vs_density(y_key, data, method, init, **plot_kwargs)

Plot a particular column vs density for a single method + init combination.

Parameters
  • y_key – The name of the column to plot (“Mean Acc” or “Acc Seed 0” for example)

  • data – Pandas DataFrame

  • method – Method to plot

  • init – Initialization scheme (“Random” or “ERK”)

  • plot_kwargs – Additional keyword arguments to pass through to the plt.plot call

visualization.main_plots.plot_method(data, method, init, color)

Plot the mean accuracy vs density of a method + init combination along with marker plots for each seed.

Parameters
  • data – Pandas DataFrame

  • method – Method to plot

  • init – Initialization scheme (“Random” or “ERK”)

  • color – Color of the line plot and markers

visualization.main_results

Run as:

python visualization/main_results.py wandb.project=cifar10 dataset=CIFAR10

python visualization/main_results.py wandb.project=cifar100 dataset=CIFAR100

visualization.main_results.get_stats_table(runs, masking_ll: List[str] = ['RigL'], init_ll: List[str] = ['Random'], suffix_ll: List[str] = [''], density_ll: List[float] = [0.1], dataset_ll: List[str] = ['CIFAR10'], reorder: bool = True, correct_SET: bool = False) → pandas.core.frame.DataFrame

Get stats saved on W&B.

List all possible choices for (masking, init, density, dataset).

We’ll try matching the exhaustive caretesian product of (masking_ll x init_ll x suffix_ll x density_ll etc).

Parameters
  • runs (wandb.api.runs) – Experiment run

  • masking_ll (List[str]) – List of sparse training techniques

  • init_ll (List[str]) – List of sparsity initialization schemes

  • suffix_ll (List[str]) – List of method suffixes.

  • density_ll (List[float]) – List of density values (1 - sparsity)

  • dataset_ll (List[str]) – List of datasets

  • reorder (bool) – sort methods alphabetically

  • correct_SET (bool) – manually correct SET results, which collapsed.

Returns

Dataframe containing test accuracies of methods

Return type

pd.DataFrame

visualization.main_results.main(cfg: omegaconf.dictconfig.DictConfig)

visualization.redist_inference_plot

visualization.redist_inference_plot.main(cfg: omegaconf.dictconfig.DictConfig)