phess2's picture
Rename figure 2 and figure 4 to be accurate
8dd84df

Figure Data Extraction and Reproduction

This folder contains the data used in Figure 2, Figure 3, and Figure 4 from the Training Lipschitz Transformer paper and scripts to reproduce the figures from the saved CSV files.

Files

  • reproduce_figures.py: Script to reproduce the figures from the saved CSV files
  • requirements.txt: Python dependencies required to run the scripts
  • figure_2/: Directory containing the CSV files for each subplot of Figure 2
  • figure_3/: Directory containing the CSV files and a PDF for Figure 3
  • figure_4/: Directory containing the CSV files for each subplot of Figure 4

Usage

1. Install Dependencies

pip install -r requirements.txt

2. Reproduce Figures

Run the reproduction script to create the figures from the CSV files:

python reproduce_figures.py

This will create:

  • figure_2_reproduced.pdf: Recreation of Figure 2
  • figure_3_reproduced.pdf: Recreation of the right panel of Figure 3
  • figure_4_reproduced.pdf: Recreation of Figure 4

CSV File Structure

Each CSV file contains the processed data for its respective subplot:

Figure 2 Files

  • figure_2_subplot_1.csv: MLP model results with frontier points for different optimizers and techniques
  • figure_2_subplot_2.csv: Transformer model results with frontier points for different optimizers and techniques

Figure 3 Files

  • figure_3_subplot_1.pdf: Contains the left panel of Figure 3 with adversarial examples pre-made from the models contained in the models/MLPs/ directory
  • figure_3_subplot_2.csv: Contains adversarial robustness data with columns for model_name, epsilon (adversarial perturbation budget), accuracy, avg_correct_prob (mean probability for correct class), and prob_error_bar (error bars for probability measurements)

Figure 4 Files

  • figure_4_subplot_1.csv: Contains points used to plot the frontier of validation loss vs. Lipschitz constant with columns for technique, learning rate, w_max, final validation loss, Lipschitz constant, optimizer, etc.
  • figure_4_subplot_2_3.csv: Contains results for top validation accuracy model for each of our tested techniques with columns for technique, learning rate, w_max, final validation accuracy, Lipschitz constant, optimizer, etc.

Reproducibility

The reproduction script creates pixel-perfect recreations of the original figures with:

  • Identical color schemes and marker styles
  • Same axis scaling and formatting
  • Matching legend positioning and styling
  • Equivalent subplot layouts and spacing

This ensures full reproducibility of Figure 2 (MLP and Transformer optimizer comparisons), Figure 3 (adversarial robustness analysis), and Figure 4 (Lipschitz weight constraints comparison) from the saved CSV data.