Skip to content

Repository files navigation

Supplementary Code: Trauma as a Functional Kind

Anonymized supplementary repository for double-blind review. Authors: Anonymized for review.

This repository contains the four computational models referred to in the paper as the artificial realizer: neural-network demonstrations that the four functional profiles of maladaptive learning specified in the paper are realizable in a substrate whose mechanism is fully known and inspectable. The models are possibility proofs, not simulations of children or clinical instruments.

Contents

supplementary-repo/
├── trauma_models/               # Main package
│   ├── core/                    # Shared base classes, metrics, plotting, logging
│   ├── extreme_penalty/         # Model 1 — gradient cascade from a single extreme penalty
│   ├── noisy_signals/           # Model 2 — inconsistent labels -> weight/behavioral instability
│   ├── limited_dataset/         # Model 3 — few caregivers -> overfitting / generalization gap
│   └── catastrophic_forgetting/ # Model 4 — retraining destroys consolidated patterns
├── experiments/                 # YAML configs (exact hyperparameters per model)
├── tests/                       # Unit tests (architectures, reproducibility, statistics)
├── outputs/                     # Committed results backing the paper's numbers
│   ├── extreme_penalty_fixed/   # Model 1 run (data + figures)
│   ├── noisy_signals/           # Model 2 run
│   ├── limited_dataset/         # Model 3 — BOTH documented runs (see below)
│   ├── catastrophic_forgetting/ # Model 4 run
│   └── data/, figures/          # Additional Model 1 outputs
├── paper-figures/               # The exact PNGs embedded in the manuscript + Figure 4 script
├── MODEL_SPECIFICATIONS.md      # Mathematical formulations of all four models
├── requirements.txt             # Dependencies (pip)
├── requirements_frozen.txt      # Exact versions used for the committed runs
├── pyproject.toml               # Package metadata
└── run_all_experiments.sh       # Convenience runner for all four models

Requirements

  • Python 3.8+ and PyTorch 2.0+
  • All models run on standard CPU hardware — no GPU required (~2–4 GB RAM; the full experiment suite runs in roughly 5–20 minutes on a laptop CPU)
python -m venv venv
source venv/bin/activate      # Windows: venv\Scripts\activate
pip install -r requirements.txt

The Four Models

Model Package Failure mode Developmental analogue
1 trauma_models.extreme_penalty Single example with extreme loss penalty causes overcorrection in the boundary region around the penalized input Single-event trauma generalizing to similar contexts
2 trauma_models.noisy_signals Label noise produces weight variance, confidence collapse, behavioral inconsistency Inconsistent caregiving / anxious-disorganized attachment
3 trauma_models.limited_dataset Training on few synthetic "caregivers" yields a generalization gap on novel ones Narrow early environment limiting generalization to new adults
4 trauma_models.catastrophic_forgetting Aggressive retraining on a small corrective set destroys consolidated patterns; experience replay preserves them Why safe therapeutic retraining is necessarily gradual

Mapping to Paper Figures, and Reproduction Commands

Note the off-by-one between graphic filenames and paper figure numbers: the file figure0_* is paper Figure 1, figure1_* is Figure 2, and so on. The exact PNGs used in the manuscript are committed in paper-figures/.

Paper figure Graphic file Generated by
Figure 1 figure0_four_categories_diagram.png Conceptual diagram (not experiment output)
Figure 2 figure1_extreme_penalty_overcorrection.png Model 1 experiment (below)
Figure 3 figure2_noisy_signals_instability.png Model 2 experiment (below)
Figure 4 figure3_limited_dataset_overfitting.png Model 3 statistical run + paper-figures/generate_figure4.py
Figure 5 figure4_catastrophic_forgetting_therapy.png Model 4 experiment (below)

Run everything from the repository root.

Figure 2 — Model 1 (extreme penalty, seed 42, single run):

python -m trauma_models.extreme_penalty.experiment \
    --config experiments/extreme_penalty_sweep.yaml --output outputs/
# -> outputs/figures/extreme_penalty_overcorrection.png
# committed reference run: outputs/extreme_penalty_fixed/

Figure 3 — Model 2 (noisy signals, 10 runs per noise level, seeds 42–51):

python -m trauma_models.noisy_signals.experiment \
    --config experiments/noisy_signals_sweep.yaml --output outputs/
# -> outputs/noisy_signals/figures/noisy_signals_analysis.png

Figure 4 — Model 3 (limited dataset, statistical run: [2, 5, 10] caregivers × 10 trials, seeds 42–51):

python -m trauma_models.limited_dataset.statistical_significance
# -> outputs/limited_dataset/statistical_significance_analysis.{json,txt}
#    outputs/limited_dataset/figures/statistical_significance.png
python paper-figures/generate_figure4.py
# -> paper-figures/figure3_limited_dataset_overfitting.png (the manuscript figure)

Figure 5 — Model 4 (catastrophic forgetting, seed 42, single run):

python -m trauma_models.catastrophic_forgetting.experiment \
    --config experiments/catastrophic_forgetting_sweep.yaml --output outputs/
# -> outputs/catastrophic_forgetting/figures/catastrophic_forgetting_comparison.png

All four models at once:

./run_all_experiments.sh

Model 3 Has Two Documented Runs — Which One Backs Figure 4

outputs/limited_dataset/ contains results from two distinct experiments:

  1. Statistical-significance run (statistical_significance_analysis.json / .txt): caregiver counts [2, 5, 10], 10 trials per condition (seeds 42–51, seed = base_seed + trial), 30 training runs total. This is the run reported in the paper and plotted in Figure 4. All Figure 4 numbers trace to it: generalization gap 0.0161 ± 0.0098 (2 caregivers) vs 0.0058 ± 0.0027 (10 caregivers), the pre-planned 2-vs-10 contrast t(18) = 3.20, p = 0.005, Cohen's d = 1.43, surviving Holm correction.

  2. Single-seed sweep (limited_dataset_results.json): caregiver counts [2, 3, 4, 5, 6, 8, 10, 12, 15, 20], one run per condition (seed 42), produced by python -m trauma_models.limited_dataset.experiment. This finer-grained sweep is retained for completeness and exploratory inspection; because each condition has n = 1, it supports no error bars or tests and is not the source of any number in the paper.

Seed Conventions

All experiments use fixed seeds; identical seeds give identical numerical results (pixel-level PNG output may vary slightly across matplotlib versions).

Model Seeding
1 — extreme_penalty Single run, seed 42 (from experiments/extreme_penalty_sweep.yaml)
2 — noisy_signals 10 runs per noise level, seeds 42–51 (run_seed = 42 + run_idx)
3 — limited_dataset (statistical run) 10 trials per condition, seeds 42–51 (seed = 42 + trial)
3 — limited_dataset (single-seed sweep) One run per condition, seed 42
4 — catastrophic_forgetting Single run, seed 42

Tests

pytest tests/

The suite covers model architectures, gradient-cascade behavior, reproducibility (same seed → same results), and the Model 3 statistical pipeline. Tests were written against the pinned versions in requirements_frozen.txt (torch 2.9.0). One behavioral assertion (test_gradient_cascade.py::test_overcorrection_increases_with_penalty) depends on the exact PyTorch build's RNG stream and has been observed to fail under a different build while the remaining 25 tests pass; it exercises a short auxiliary training loop, not the committed results, which were produced with the frozen environment.

License

MIT (see LICENSE). Copyright holder anonymized for review.

About

Simulation code and outputs for research on maladaptive learning dynamics: four PyTorch models, test suite, and reproducible figure pipeline

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages