Simplify to separate within-dataset layer-16 classifiers
Browse files- README.md +22 -46
- notebook_execution.json +7 -0
- temporal_coherence_colab.ipynb +194 -1125
- temporal_coherence_colab_executed.ipynb +0 -0
- verification.json +81 -69
- within_dataset_results.csv +9 -0
README.md
CHANGED
|
@@ -1,58 +1,34 @@
|
|
| 1 |
---
|
| 2 |
-
pretty_name: V-JEPA 2
|
| 3 |
-
|
| 4 |
-
- video-classification
|
| 5 |
-
tags:
|
| 6 |
-
- temporal-coherence
|
| 7 |
-
- vjepa2
|
| 8 |
-
- reproducibility
|
| 9 |
-
- colab
|
| 10 |
---
|
| 11 |
|
| 12 |
-
#
|
| 13 |
|
| 14 |
-
[**Open
|
| 15 |
|
| 16 |
-
|
| 17 |
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|---|---|
|
| 22 |
-
| `temporal_coherence_colab.ipynb` | Start-to-finish notebook with explanations and concise stage calls |
|
| 23 |
-
| `runtime.zip` | Full Python implementations and fixed study protocols; no feature caches or predictions |
|
| 24 |
-
| `mat_raw_frames.zip` | Lossless raw pixels and frame indices for the two supplied MAT files |
|
| 25 |
|
| 26 |
-
|
| 27 |
|
| 28 |
-
##
|
| 29 |
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
-
|
| 33 |
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
| Asset | Pinned upstream revision |
|
| 37 |
-
|---|---|
|
| 38 |
-
| [facebook/vjepa2-vitl-fpc64-256](https://huggingface.co/facebook/vjepa2-vitl-fpc64-256) | `b3c1679b7c34d3255ef3547f27c7b226aefab26f` |
|
| 39 |
-
| [sayakpaul/ucf101-subset](https://huggingface.co/datasets/sayakpaul/ucf101-subset) | `b9984b8d2a95e4a1879e1b071e9433858d0bc24a` |
|
| 40 |
-
| [facebook/IntPhys2](https://huggingface.co/datasets/facebook/IntPhys2) | `a077a2f94e25889016fc6e5983cf21e2ddc25fb2` |
|
| 41 |
-
|
| 42 |
-
The model weights, UCF archive, and IntPhys2 videos are fetched directly from their upstream repositories and remain subject to their original terms. IntPhys2 is used only for evaluation, without training or calibration on its labels.
|
| 43 |
-
|
| 44 |
-
## What the score means
|
| 45 |
-
|
| 46 |
-
Frame-order ranking, playback-direction discrimination, and physical plausibility are different tests. Good performance on synthetic shuffling does not establish a general coherence measure. Pixel baselines, held-out sources/actions, full reversals, and direction-information nulls are included to constrain the interpretation. Numerical comments from the original local run are labeled separately from newly generated tables; the notebook ends with a direct comparison.
|
| 47 |
-
|
| 48 |
-
## Reproduction records
|
| 49 |
-
|
| 50 |
-
The notebook saves its cold-start status, all stage logs, raw-pixel checks, feature reproduction checks, fitted readouts, predictions, package versions, and final validation record. Its final cell creates `colab_results.zip`; the raw downloads remain separate. Save the executed notebook through Colab's **File → Download → Download .ipynb** menu.
|
| 51 |
-
|
| 52 |
-
## Colab validation on 27 September 2026
|
| 53 |
-
|
| 54 |
-
On an NVIDIA L4, all seven experimental stages regenerated from raw inputs with **zero preexisting features or predictions**, taking approximately 37 minutes. After fixing a report cell's missing audit-file dependency, a clean kernel ran **all 34 corrected code cells with zero errors** in 9 minutes 21 seconds, reusing those newly generated features. This records the two runs explicitly; the final full-notebook run was cached.
|
| 55 |
-
|
| 56 |
-
The arrow-of-time probe at layer 16 achieved **72% pair accuracy on held-out sources** (95% interval 64–80%) and **51% on held-out action categories** (42–60%); chance is 50%. The original local run gave 73% and 49%, respectively. The interpretation is unchanged: direction cues are detectable within the tested action categories, with no demonstrated transfer to new categories. The notebook also completed 100 label-permutation refits and the static/palindrome null checks.
|
| 57 |
-
|
| 58 |
-
See `verification.json` for the execution receipt and `colab_observed_aot_summary.csv` for the retrieved direction metrics. The temporary runtime expired before its final executed notebook and results ZIP were downloaded. The source notebook delivered here has cleared outputs; the successful execution log and retrieved metric tables are retained locally. Run all to recreate the full output archive.
|
|
|
|
| 1 |
---
|
| 2 |
+
pretty_name: V-JEPA 2 layer-16 probes within each dataset
|
| 3 |
+
tags: [temporal-coherence, vjepa2, colab]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
---
|
| 5 |
|
| 6 |
+
# Layer 16: separate classifiers within each dataset
|
| 7 |
|
| 8 |
+
[**Open in Colab**](https://colab.research.google.com/gist/UYildiz12/fa02787a1a0d611b613219cdd53fa859/temporal_coherence_colab.ipynb). Select **L4/A100 → Run all**. Downloads are anonymous; no Drive mount is needed.
|
| 9 |
|
| 10 |
+
Each task trains its **own linear classifier** on frozen layer-16 features, with training-only scaling and grouped cross-validation. Held-out scenes test whether a shared readout works within that dataset. Failure does not establish that the layer lacks the information. Classifier weights never transfer between datasets.
|
| 11 |
|
| 12 |
+
| Task | Labels | Groups kept together |
|
| 13 |
+
|---|---|---|
|
| 14 |
+
| MAT order | Intact / shuffled, including reversals | Four source variants |
|
| 15 |
+
| UCF order | Intact / shuffled, including reversals | 100 source groups |
|
| 16 |
+
| UCF direction | Forward / reverse intact videos | The same 100 groups |
|
| 17 |
+
| IntPhys continuity | Possible / impossible | 60 matched scenes |
|
| 18 |
|
| 19 |
+
The notebook has **7 code cells**, 169 code lines and 241 words of explanation. Pixel change is the order/continuity baseline; endpoint pixels are the direction baseline. IntPhys probing is exploratory and differs from its standard benchmark protocol. MAT sources are closely related; human coherence ratings remain unmeasured.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
+
**Verified on 2026-09-29:** all seven code cells completed on an NVIDIA L4 in 15 min 43 s, encoding all 1,296 inputs. Layer-16 held-out balanced accuracy: MAT order 100%, UCF order 94.6%, UCF direction 55.5%, IntPhys continuity 58.8%. These estimates alone do not establish statistical significance. Pixel change ranked intact above shuffled videos perfectly within sources, so order classification remains compatible with simple visual cues.
|
| 22 |
|
| 23 |
+
## Files
|
| 24 |
|
| 25 |
+
- `temporal_coherence_colab.ipynb`: complete raw-input workflow.
|
| 26 |
+
- `temporal_coherence_colab_executed.ipynb`: the same notebook with verified outputs.
|
| 27 |
+
- `within_dataset_results.csv`: current probe results; `verification.json` records checks and hashes.
|
| 28 |
+
- `ucf_sources.json`: fixed source selection and frame indices.
|
| 29 |
+
- `mat_raw_frames.zip`: lossless original pixels and frame orders; the defective two-frame condition is excluded during analysis.
|
| 30 |
+
- `archive/supervised_study/`: the previous study and its separate execution record.
|
| 31 |
|
| 32 |
+
The notebook pins the [model](https://huggingface.co/facebook/vjepa2-vitl-fpc64-256), [UCF](https://huggingface.co/datasets/sayakpaul/ucf101-subset) and [IntPhys2](https://huggingface.co/datasets/facebook/IntPhys2) revisions and downloads their assets directly. Their original terms apply. The supplied MAT stimuli have no asserted redistribution license.
|
| 33 |
|
| 34 |
+
Results, features and held-out predictions are saved to `/content/layer16_within_dataset_results.zip`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
notebook_execution.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"elapsed_seconds": 942.6834290027618,
|
| 3 |
+
"errors": [],
|
| 4 |
+
"executed_code_cells": 7,
|
| 5 |
+
"source_sha256": "5ad5ef99c2b96a6eba2c238cc42e6454bc62c36b7974dd44b0f946280d860f0c",
|
| 6 |
+
"executed_sha256": "518e3825593287bc1f1edf197716197e4d3712f877de194be95d51a80b3f52f6"
|
| 7 |
+
}
|
temporal_coherence_colab.ipynb
CHANGED
|
@@ -2,1244 +2,314 @@
|
|
| 2 |
"cells": [
|
| 3 |
{
|
| 4 |
"cell_type": "markdown",
|
| 5 |
-
"id": "
|
| 6 |
"metadata": {},
|
| 7 |
"source": [
|
| 8 |
-
"#
|
| 9 |
"\n",
|
| 10 |
-
"**
|
| 11 |
"\n",
|
| 12 |
-
"
|
| 13 |
-
"\n",
|
| 14 |
-
"**No Drive mount, account token, data-access approval, or local experiment folder is required.** All inputs are publicly downloadable. The model and external videos come from pinned source revisions. The two supplied MAT files are stored as a lossless raw-frame bundle: all 32 original pixel arrays and frame orders are reconstructed and checked, including the known two-frame-condition anomaly. The bundle contains no features or predictions.\n",
|
| 15 |
-
"\n",
|
| 16 |
-
"Every readout is fitted in this runtime. The encoder stays frozen and its predictor is unused. After computation, the report recomputes metrics and presents the evidence. Historical numerical comments are explicitly labeled; generated tables and the final comparison describe this run. Small changes across GPU/software versions are possible.\n",
|
| 17 |
-
"\n",
|
| 18 |
-
"Layer 16 was selected after exploratory comparisons. Human ratings remain deferred. Study seed: **20260927**."
|
| 19 |
-
]
|
| 20 |
-
},
|
| 21 |
-
{
|
| 22 |
-
"cell_type": "markdown",
|
| 23 |
-
"id": "09a345b3",
|
| 24 |
-
"metadata": {},
|
| 25 |
-
"source": [
|
| 26 |
-
"## A. Install and fetch the reproducible inputs\n",
|
| 27 |
-
"\n",
|
| 28 |
-
"We retain Colab's CUDA/PyTorch installation and install the small dependencies used by the experiment. Raw downloads can be reused on a second run. Derived features can also resume within the same runtime, but a fresh Colab session starts with none; the next cell records that fact.\n",
|
| 29 |
-
"\n",
|
| 30 |
-
"The downloaded runtime contains the original analysis scripts with portable paths and fonts. Keeping them in one versioned bundle makes the notebook short while preserving the full implementation for inspection under `/content/temporal_coherence_rebuild/work/temporal_coherence`."
|
| 31 |
-
]
|
| 32 |
-
},
|
| 33 |
-
{
|
| 34 |
-
"cell_type": "code",
|
| 35 |
-
"execution_count": null,
|
| 36 |
-
"id": "f7155f1f",
|
| 37 |
-
"metadata": {},
|
| 38 |
-
"outputs": [],
|
| 39 |
-
"source": [
|
| 40 |
-
"import os, sys, subprocess, time, json, hashlib, zipfile\n",
|
| 41 |
-
"from pathlib import Path\n",
|
| 42 |
-
"os.environ.update(HF_HUB_DISABLE_IMPLICIT_TOKEN='1', HF_HUB_DISABLE_PROGRESS_BARS='1',\n",
|
| 43 |
-
" OMP_NUM_THREADS='4', OPENBLAS_NUM_THREADS='4', MKL_NUM_THREADS='4', MPLBACKEND='Agg')\n",
|
| 44 |
-
"subprocess.run([sys.executable, '-m', 'pip', 'install', '-q',\n",
|
| 45 |
-
" 'transformers==5.15.1', 'pillow==12.3.0', 'imageio==2.37.4', 'imageio-ffmpeg==0.6.0',\n",
|
| 46 |
-
" 'scikit-learn==1.6.1', 'opencv-python-headless==4.13.0.92', 'gdown', 'nbformat', 'nbclient'], check=True)\n",
|
| 47 |
-
"import torch\n",
|
| 48 |
-
"assert torch.cuda.is_available(), 'Select a GPU runtime, then run again.'\n",
|
| 49 |
-
"assert torch.cuda.is_bf16_supported(including_emulation=False), 'Use an L4/A100 or another GPU with native bfloat16 support.'\n",
|
| 50 |
-
"ROOT = Path('/content/temporal_coherence_rebuild')\n",
|
| 51 |
-
"DATA = ROOT/'data'\n",
|
| 52 |
-
"DATA.mkdir(parents=True, exist_ok=True)\n",
|
| 53 |
-
"STARTED = time.time()\n",
|
| 54 |
-
"print('GPU:', torch.cuda.get_device_name(), '| Python:', sys.version.split()[0], '| Torch:', torch.__version__)"
|
| 55 |
-
]
|
| 56 |
-
},
|
| 57 |
-
{
|
| 58 |
-
"cell_type": "code",
|
| 59 |
-
"execution_count": null,
|
| 60 |
-
"id": "ae0e8b2f",
|
| 61 |
-
"metadata": {},
|
| 62 |
-
"outputs": [],
|
| 63 |
-
"source": [
|
| 64 |
-
"from huggingface_hub import hf_hub_download, snapshot_download\n",
|
| 65 |
-
"BUNDLE_REPO = 'Iuda/vjepa-temporal-coherence'\n",
|
| 66 |
-
"BUNDLE_REVISION = '85b6a55f474a04a36a3149c45a6d9a3598f7c981'\n",
|
| 67 |
-
"EXPECTED = {\n",
|
| 68 |
-
" 'runtime.zip': '270297d3b7b705aab8c1177f7581af435a5480f8c65571d1985068a783deef91',\n",
|
| 69 |
-
" 'mat_raw_frames.zip': '67f6e6eff15fb0eac0d5e7b7545faa2c02fcec063db038d717f424736ec25941'}\n",
|
| 70 |
-
"initial_features = list((ROOT/'outputs').rglob('*.npz'))\n",
|
| 71 |
-
"initial_predictions = list((ROOT/'outputs').rglob('*predictions*.csv'))\n",
|
| 72 |
-
"start_record = {'started_utc': time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime()),\n",
|
| 73 |
-
" 'preexisting_feature_files': len(initial_features), 'preexisting_prediction_files': len(initial_predictions),\n",
|
| 74 |
-
" 'cold_start': not (initial_features or initial_predictions), 'anonymous_downloads': True,\n",
|
| 75 |
-
" 'bundle_revision': BUNDLE_REVISION, 'gpu': torch.cuda.get_device_name()}\n",
|
| 76 |
-
"for filename, expected in EXPECTED.items():\n",
|
| 77 |
-
" path = Path(hf_hub_download(BUNDLE_REPO, filename, repo_type='dataset',\n",
|
| 78 |
-
" revision=BUNDLE_REVISION, local_dir=DATA, token=False))\n",
|
| 79 |
-
" assert hashlib.sha256(path.read_bytes()).hexdigest() == expected, filename + ' checksum mismatch'\n",
|
| 80 |
-
"with zipfile.ZipFile(DATA/'runtime.zip') as archive:\n",
|
| 81 |
-
" assert all((ROOT/name).resolve().is_relative_to(ROOT.resolve()) for name in archive.namelist())\n",
|
| 82 |
-
" archive.extractall(ROOT)\n",
|
| 83 |
-
"(ROOT/'logs').mkdir(exist_ok=True)\n",
|
| 84 |
-
"receipt = ROOT/'logs/cold_start.json'\n",
|
| 85 |
-
"if start_record['cold_start'] or not receipt.exists(): receipt.write_text(json.dumps(start_record, indent=2))\n",
|
| 86 |
-
"print('This invocation:', start_record)"
|
| 87 |
-
]
|
| 88 |
-
},
|
| 89 |
-
{
|
| 90 |
-
"cell_type": "code",
|
| 91 |
-
"execution_count": null,
|
| 92 |
-
"id": "dd9adee7",
|
| 93 |
-
"metadata": {},
|
| 94 |
-
"outputs": [],
|
| 95 |
-
"source": [
|
| 96 |
-
"MODEL_REVISION = 'b3c1679b7c34d3255ef3547f27c7b226aefab26f'\n",
|
| 97 |
-
"UCF_REVISION = 'b9984b8d2a95e4a1879e1b071e9433858d0bc24a'\n",
|
| 98 |
-
"INTPHYS_REVISION = 'a077a2f94e25889016fc6e5983cf21e2ddc25fb2'\n",
|
| 99 |
-
"snapshot_download('facebook/vjepa2-vitl-fpc64-256', revision=MODEL_REVISION,\n",
|
| 100 |
-
" local_dir=DATA/'models/vjepa2-vitl-fpc64-256', token=False,\n",
|
| 101 |
-
" allow_patterns=['config.json', 'video_preprocessor_config.json', 'model.safetensors', 'README.md'])\n",
|
| 102 |
-
"snapshot_download('sayakpaul/ucf101-subset', repo_type='dataset', revision=UCF_REVISION,\n",
|
| 103 |
-
" local_dir=DATA/'external_stimuli/UCF101_subset', token=False,\n",
|
| 104 |
-
" allow_patterns=['UCF101_subset.tar.gz', 'README.md'])\n",
|
| 105 |
-
"intphys = DATA/'external_stimuli/IntPhys2'\n",
|
| 106 |
-
"snapshot_download('facebook/IntPhys2', repo_type='dataset', revision=INTPHYS_REVISION,\n",
|
| 107 |
-
" local_dir=intphys, token=False, allow_patterns=['Main/metadata.csv', 'README.md'])\n",
|
| 108 |
-
"import pandas as pd\n",
|
| 109 |
-
"metadata = pd.read_csv(intphys/'Main/metadata.csv', keep_default_na=False)\n",
|
| 110 |
-
"paths = ['Main/'+s for s in metadata.loc[metadata.condition.eq('continuity'), 'file_name']]\n",
|
| 111 |
-
"assert len(paths) == 240\n",
|
| 112 |
-
"snapshot_download('facebook/IntPhys2', repo_type='dataset', revision=INTPHYS_REVISION,\n",
|
| 113 |
-
" local_dir=intphys, token=False, allow_patterns=paths)\n",
|
| 114 |
-
"sys.path.insert(0, str(ROOT/'work/temporal_coherence'))\n",
|
| 115 |
-
"import colab_pipeline as pipeline\n",
|
| 116 |
-
"print('Raw inputs ready. All downloads explicitly used token=False.')"
|
| 117 |
-
]
|
| 118 |
-
},
|
| 119 |
-
{
|
| 120 |
-
"cell_type": "markdown",
|
| 121 |
-
"id": "081207bb",
|
| 122 |
-
"metadata": {},
|
| 123 |
-
"source": [
|
| 124 |
-
"## B1. Restore and audit the original stimuli\n",
|
| 125 |
-
"\n",
|
| 126 |
-
"Reconstruct the 32 original MAT cells, verify every raw pixel hash, and create deterministic 64- and 90-frame model inputs. Preview movies are for inspection only.\n",
|
| 127 |
-
"\n",
|
| 128 |
-
"Complete subprocess logs are saved under `ROOT/logs`. A failed stage raises an error; later stages require its completion receipt."
|
| 129 |
-
]
|
| 130 |
-
},
|
| 131 |
-
{
|
| 132 |
-
"cell_type": "code",
|
| 133 |
-
"execution_count": null,
|
| 134 |
-
"id": "ea411ae4",
|
| 135 |
-
"metadata": {},
|
| 136 |
-
"outputs": [],
|
| 137 |
-
"source": [
|
| 138 |
-
"pipeline.stage('mat')"
|
| 139 |
-
]
|
| 140 |
-
},
|
| 141 |
-
{
|
| 142 |
-
"cell_type": "markdown",
|
| 143 |
-
"id": "7daa4b61",
|
| 144 |
-
"metadata": {},
|
| 145 |
-
"source": [
|
| 146 |
-
"## B2. Rebuild the historical pilot\n",
|
| 147 |
-
"\n",
|
| 148 |
-
"Run the frozen encoder on the original supplied cells and additional shuffles; fit the original cross-family readouts. The supplied cells already contain shuffle levels, so this is an additional-disruption pilot.\n",
|
| 149 |
-
"\n",
|
| 150 |
-
"Complete subprocess logs are saved under `ROOT/logs`. A failed stage raises an error; later stages require its completion receipt."
|
| 151 |
-
]
|
| 152 |
-
},
|
| 153 |
-
{
|
| 154 |
-
"cell_type": "code",
|
| 155 |
-
"execution_count": null,
|
| 156 |
-
"id": "fafc0c73",
|
| 157 |
-
"metadata": {},
|
| 158 |
-
"outputs": [],
|
| 159 |
-
"source": [
|
| 160 |
-
"pipeline.stage('pilot')"
|
| 161 |
-
]
|
| 162 |
-
},
|
| 163 |
-
{
|
| 164 |
-
"cell_type": "markdown",
|
| 165 |
-
"id": "f7db2129",
|
| 166 |
-
"metadata": {},
|
| 167 |
-
"source": [
|
| 168 |
-
"## B3. Compare layers 16–22 and 24\n",
|
| 169 |
-
"\n",
|
| 170 |
-
"Extract all requested layers in each forward pass, recover the stored shuffle orders from image content, and fit the cross-family probes with and without anomalous version 2.\n",
|
| 171 |
-
"\n",
|
| 172 |
-
"Complete subprocess logs are saved under `ROOT/logs`. A failed stage raises an error; later stages require its completion receipt."
|
| 173 |
-
]
|
| 174 |
-
},
|
| 175 |
-
{
|
| 176 |
-
"cell_type": "code",
|
| 177 |
-
"execution_count": null,
|
| 178 |
-
"id": "fb4132fd",
|
| 179 |
-
"metadata": {},
|
| 180 |
-
"outputs": [],
|
| 181 |
-
"source": [
|
| 182 |
-
"pipeline.stage('layers')"
|
| 183 |
-
]
|
| 184 |
-
},
|
| 185 |
-
{
|
| 186 |
-
"cell_type": "markdown",
|
| 187 |
-
"id": "d3c2561d",
|
| 188 |
-
"metadata": {},
|
| 189 |
-
"source": [
|
| 190 |
-
"## B4. Test reversal tolerance and graded order\n",
|
| 191 |
-
"\n",
|
| 192 |
-
"Generate fresh exact frame permutations, preserve source-family separation, and fit the regularized ranking heads. Evaluate held-out templates and full reversals.\n",
|
| 193 |
-
"\n",
|
| 194 |
-
"Complete subprocess logs are saved under `ROOT/logs`. A failed stage raises an error; later stages require its completion receipt."
|
| 195 |
-
]
|
| 196 |
-
},
|
| 197 |
-
{
|
| 198 |
-
"cell_type": "code",
|
| 199 |
-
"execution_count": null,
|
| 200 |
-
"id": "cef73bba",
|
| 201 |
-
"metadata": {},
|
| 202 |
-
"outputs": [],
|
| 203 |
-
"source": [
|
| 204 |
-
"pipeline.stage('graded')"
|
| 205 |
-
]
|
| 206 |
-
},
|
| 207 |
-
{
|
| 208 |
-
"cell_type": "markdown",
|
| 209 |
-
"id": "a8f136b6",
|
| 210 |
-
"metadata": {},
|
| 211 |
-
"source": [
|
| 212 |
-
"## B5. Transfer frozen readouts to IntPhys2\n",
|
| 213 |
-
"\n",
|
| 214 |
-
"Evaluate the previously fitted MAT heads on all 120 native continuity pairs and predetermined controls. IntPhys2 labels never train or calibrate a readout.\n",
|
| 215 |
-
"\n",
|
| 216 |
-
"Complete subprocess logs are saved under `ROOT/logs`. A failed stage raises an error; later stages require its completion receipt."
|
| 217 |
-
]
|
| 218 |
-
},
|
| 219 |
-
{
|
| 220 |
-
"cell_type": "code",
|
| 221 |
-
"execution_count": null,
|
| 222 |
-
"id": "1ab1986b",
|
| 223 |
-
"metadata": {},
|
| 224 |
-
"outputs": [],
|
| 225 |
-
"source": [
|
| 226 |
-
"pipeline.stage('physical')"
|
| 227 |
-
]
|
| 228 |
-
},
|
| 229 |
-
{
|
| 230 |
-
"cell_type": "markdown",
|
| 231 |
-
"id": "e87b32c7",
|
| 232 |
-
"metadata": {},
|
| 233 |
-
"source": [
|
| 234 |
-
"## B6. Repeat the controlled study on 100 UCF source groups\n",
|
| 235 |
-
"\n",
|
| 236 |
-
"Select the fixed sources, generate all order conditions, extract layer 16, and fit grouped readouts plus pixel/motion baselines. Source folds and action holdouts keep all derivatives together.\n",
|
| 237 |
-
"\n",
|
| 238 |
-
"Complete subprocess logs are saved under `ROOT/logs`. A failed stage raises an error; later stages require its completion receipt."
|
| 239 |
-
]
|
| 240 |
-
},
|
| 241 |
-
{
|
| 242 |
-
"cell_type": "code",
|
| 243 |
-
"execution_count": null,
|
| 244 |
-
"id": "0b37ed5a",
|
| 245 |
-
"metadata": {},
|
| 246 |
-
"outputs": [],
|
| 247 |
-
"source": [
|
| 248 |
-
"pipeline.stage('broad')"
|
| 249 |
-
]
|
| 250 |
-
},
|
| 251 |
-
{
|
| 252 |
-
"cell_type": "markdown",
|
| 253 |
-
"id": "b610a7a7",
|
| 254 |
-
"metadata": {},
|
| 255 |
-
"source": [
|
| 256 |
-
"## B7. Test arrow of time and related controls\n",
|
| 257 |
-
"\n",
|
| 258 |
-
"Extract new local reversals, shifts, static videos and palindromes; fit direction heads using intact forward/reverse pairs only. Run 100 refitted label permutations and evaluate the frozen order heads on the new controls.\n",
|
| 259 |
-
"\n",
|
| 260 |
-
"Complete subprocess logs are saved under `ROOT/logs`. A failed stage raises an error; later stages require its completion receipt."
|
| 261 |
]
|
| 262 |
},
|
| 263 |
{
|
| 264 |
"cell_type": "code",
|
| 265 |
"execution_count": null,
|
| 266 |
-
"id": "
|
| 267 |
"metadata": {},
|
| 268 |
"outputs": [],
|
| 269 |
"source": [
|
| 270 |
-
"
|
| 271 |
-
]
|
| 272 |
-
},
|
| 273 |
-
{
|
| 274 |
-
"cell_type": "markdown",
|
| 275 |
-
"id": "a9f900bc",
|
| 276 |
-
"metadata": {},
|
| 277 |
-
"source": [
|
| 278 |
-
"## C. Inspect the regenerated evidence\n",
|
| 279 |
-
"\n",
|
| 280 |
-
"Everything below reads the outputs just produced in this Colab runtime. Numerical prose labeled **original reference run** is retained to explain the earlier study. It is not substituted for a new measurement. The final comparison puts regenerated metrics beside those references."
|
| 281 |
-
]
|
| 282 |
-
},
|
| 283 |
-
{
|
| 284 |
-
"cell_type": "markdown",
|
| 285 |
-
"id": "19294777",
|
| 286 |
-
"metadata": {},
|
| 287 |
-
"source": [
|
| 288 |
-
"## 1. Four different meanings of “temporal”\n",
|
| 289 |
-
"\n",
|
| 290 |
-
"| Question | Operational test here | What success would establish |\n",
|
| 291 |
-
"|---|---|---|\n",
|
| 292 |
-
"| Frame-order disruption | Intact versus shuffled; longer versus shorter retained blocks | A readout detects the constructed manipulation |\n",
|
| 293 |
-
"| Temporal continuity | Sensitivity to local reversals and new boundaries | Descriptive sensitivity; no human label was collected |\n",
|
| 294 |
-
"| Arrow of time | Stored forward playback versus full reversal | Direction information accessible to the chosen readout |\n",
|
| 295 |
-
"| Physical plausibility / perceived coherence | IntPhys2 possible versus impossible events / human ratings | Transfer to that physical task / agreement with observers |\n",
|
| 296 |
-
"\n",
|
| 297 |
-
"Shuffling is a useful first proxy because it changes order while keeping the same images. Longer retained blocks usually preserve more local motion. However, shuffling also increases simple pixel differences, so success need not involve event understanding. Full reversal preserves adjacent **undirected** pixel differences and can remain smooth and coherent. It tests a different property.\n",
|
| 298 |
-
"\n",
|
| 299 |
-
"A linear probe asks whether a weighted combination of features predicts a target. It does not isolate dedicated neurons, prove causal necessity, or remove every other variable represented by the layer."
|
| 300 |
-
]
|
| 301 |
-
},
|
| 302 |
-
{
|
| 303 |
-
"cell_type": "code",
|
| 304 |
-
"execution_count": null,
|
| 305 |
-
"id": "0f7ddfbd",
|
| 306 |
-
"metadata": {
|
| 307 |
-
"execution": {
|
| 308 |
-
"iopub.execute_input": "2026-09-27T13:37:57.606588Z",
|
| 309 |
-
"iopub.status.busy": "2026-09-27T13:37:57.606588Z",
|
| 310 |
-
"iopub.status.idle": "2026-09-27T13:37:58.258972Z",
|
| 311 |
-
"shell.execute_reply": "2026-09-27T13:37:58.258972Z"
|
| 312 |
-
}
|
| 313 |
-
},
|
| 314 |
-
"outputs": [],
|
| 315 |
-
"source": [
|
| 316 |
"from pathlib import Path\n",
|
| 317 |
-
"
|
|
|
|
|
|
|
| 318 |
"import numpy as np\n",
|
| 319 |
"import pandas as pd\n",
|
| 320 |
"import matplotlib.pyplot as plt\n",
|
| 321 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 322 |
"\n",
|
|
|
|
| 323 |
"SEED = 20260927\n",
|
| 324 |
-
"
|
| 325 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 326 |
"\n",
|
| 327 |
-
"def
|
| 328 |
-
"
|
| 329 |
-
"pd.set_option('display.max_columns', 12)\n",
|
| 330 |
-
"print('Results:', BASE)"
|
| 331 |
]
|
| 332 |
},
|
| 333 |
{
|
| 334 |
"cell_type": "markdown",
|
| 335 |
-
"id": "
|
| 336 |
"metadata": {},
|
| 337 |
"source": [
|
| 338 |
-
"##
|
| 339 |
-
"\n",
|
| 340 |
-
"Each MAT contains **16 cells**, each with 90 RGB frames at 570 × 570. There are eight block-order versions for each of two variants, giving 32 cells across dragging and rotation. Cells 8 and 16 were inferred to be intact references. The two variants are **not exact horizontal mirrors**; their precise generating relationship is unknown.\n",
|
| 341 |
"\n",
|
| 342 |
-
"
|
| 343 |
]
|
| 344 |
},
|
| 345 |
{
|
| 346 |
"cell_type": "code",
|
| 347 |
"execution_count": null,
|
| 348 |
-
"id": "
|
| 349 |
-
"metadata": {
|
| 350 |
-
"execution": {
|
| 351 |
-
"iopub.execute_input": "2026-09-27T13:37:58.259977Z",
|
| 352 |
-
"iopub.status.busy": "2026-09-27T13:37:58.259977Z",
|
| 353 |
-
"iopub.status.idle": "2026-09-27T13:37:58.274862Z",
|
| 354 |
-
"shell.execute_reply": "2026-09-27T13:37:58.274862Z"
|
| 355 |
-
}
|
| 356 |
-
},
|
| 357 |
-
"outputs": [],
|
| 358 |
-
"source": [
|
| 359 |
-
"audit = csv('stored_layers_16_22/recovered_conditions.csv')\n",
|
| 360 |
-
"display(audit.groupby('source_group').agg(cells=('clip_id', 'size'),\n",
|
| 361 |
-
" intact_cells=('intact_inferred', 'sum'), min_unique_frames=('unique_frames', 'min')))\n",
|
| 362 |
-
"display(audit.query('unique_frames < 90')[['clip_id', 'unique_frames',\n",
|
| 363 |
-
" 'duplicated_reference_frames_one_based', 'missing_reference_frames_one_based']])"
|
| 364 |
-
]
|
| 365 |
-
},
|
| 366 |
-
{
|
| 367 |
-
"cell_type": "markdown",
|
| 368 |
-
"id": "4eeff9b2",
|
| 369 |
"metadata": {},
|
| 370 |
-
"source": [
|
| 371 |
-
"The following map shows the recovered frame positions. A smooth rising run means consecutive original frames survived together. Short blocks create many discontinuities. The mapping is inferred from frame content, rather than trusted from the cell number alone."
|
| 372 |
-
]
|
| 373 |
-
},
|
| 374 |
-
{
|
| 375 |
-
"cell_type": "code",
|
| 376 |
-
"execution_count": null,
|
| 377 |
-
"id": "cb7aa547",
|
| 378 |
-
"metadata": {
|
| 379 |
-
"execution": {
|
| 380 |
-
"iopub.execute_input": "2026-09-27T13:37:58.275867Z",
|
| 381 |
-
"iopub.status.busy": "2026-09-27T13:37:58.275867Z",
|
| 382 |
-
"iopub.status.idle": "2026-09-27T13:37:58.367949Z",
|
| 383 |
-
"shell.execute_reply": "2026-09-27T13:37:58.367949Z"
|
| 384 |
-
}
|
| 385 |
-
},
|
| 386 |
"outputs": [],
|
| 387 |
"source": [
|
| 388 |
-
"
|
| 389 |
-
"
|
| 390 |
-
"
|
| 391 |
-
"
|
| 392 |
-
"
|
| 393 |
-
" xlabel='Playback frame position', ylabel='Retained block length')\n",
|
| 394 |
-
"fig.colorbar(im, ax=ax, label='Frame position in inferred intact reference')\n",
|
| 395 |
-
"plt.show()"
|
| 396 |
-
]
|
| 397 |
-
},
|
| 398 |
-
{
|
| 399 |
-
"cell_type": "markdown",
|
| 400 |
-
"id": "64716a50",
|
| 401 |
-
"metadata": {},
|
| 402 |
-
"source": [
|
| 403 |
-
"## 3. What exactly is “layer 16”?\n",
|
| 404 |
"\n",
|
| 405 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 406 |
"\n",
|
| 407 |
-
"
|
| 408 |
-
"
|
| 409 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 410 |
"\n",
|
| 411 |
-
"
|
| 412 |
-
"\n",
|
| 413 |
-
"
|
| 414 |
-
|
| 415 |
-
|
| 416 |
-
|
| 417 |
-
|
| 418 |
-
|
| 419 |
-
|
| 420 |
-
|
| 421 |
-
"
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
"outputs": [],
|
| 429 |
-
"source": [
|
| 430 |
-
"env = saved_json('stored_layers_16_22/environment.json')\n",
|
| 431 |
-
"display(pd.Series({k: env[k] for k in ['model_repo', 'model_revision', 'model_sha256',\n",
|
| 432 |
-
" 'torch', 'transformers', 'dtype', 'gpu']}, name='Recorded value').to_frame())"
|
| 433 |
]
|
| 434 |
},
|
| 435 |
{
|
| 436 |
"cell_type": "markdown",
|
| 437 |
-
"id": "
|
| 438 |
"metadata": {},
|
| 439 |
"source": [
|
| 440 |
-
"##
|
| 441 |
-
"\n",
|
| 442 |
-
"The first pilot applied more shuffling to every supplied cell before we knew those cells already contained shuffle levels. Its numbers remain useful as a procedural pilot, but its “original” condition is **not a verified coherent condition**. It used final-layer pooling and 64 frames, so it is not a clean comparison of layer 24 against the later layer-16 experiments.\n",
|
| 443 |
"\n",
|
| 444 |
-
"
|
| 445 |
]
|
| 446 |
},
|
| 447 |
{
|
| 448 |
"cell_type": "code",
|
| 449 |
"execution_count": null,
|
| 450 |
-
"id": "
|
| 451 |
-
"metadata": {
|
| 452 |
-
"execution": {
|
| 453 |
-
"iopub.execute_input": "2026-09-27T13:37:58.375255Z",
|
| 454 |
-
"iopub.status.busy": "2026-09-27T13:37:58.373945Z",
|
| 455 |
-
"iopub.status.idle": "2026-09-27T13:37:58.382287Z",
|
| 456 |
-
"shell.execute_reply": "2026-09-27T13:37:58.382287Z"
|
| 457 |
-
}
|
| 458 |
-
},
|
| 459 |
-
"outputs": [],
|
| 460 |
-
"source": [
|
| 461 |
-
"pilot = pd.read_csv(PILOT / 'cross_family_metrics.csv')\n",
|
| 462 |
-
"display(pilot.groupby(['task', 'method'])[['auc', 'balanced_accuracy']].mean().round(3))"
|
| 463 |
-
]
|
| 464 |
-
},
|
| 465 |
-
{
|
| 466 |
-
"cell_type": "markdown",
|
| 467 |
-
"id": "22f86068",
|
| 468 |
"metadata": {},
|
| 469 |
-
"source": [
|
| 470 |
-
"> **Original reference run:** numerical commentary below describes the earlier local run. Generated tables/plots show this Colab run; compare them in section D.\n",
|
| 471 |
-
"\n",
|
| 472 |
-
"**Comment:** The final-layer frame-shuffle probe had good ranking but 50% balanced accuracy. The corrected interpretation is additional-disruption sensitivity. We do not count this as evidence of a general coherence classifier.\n",
|
| 473 |
-
"\n",
|
| 474 |
-
"## 5. Exploratory layers 16–22, with layer 24 as a reference\n",
|
| 475 |
-
"\n",
|
| 476 |
-
"The follow-up used the stored 90-frame versions and evaluated intact versus shuffled across drag/rotate families. The table compares normalized features, first with all cells and then excluding anomalous version 2. This is exploratory layer selection on tiny, related source material."
|
| 477 |
-
]
|
| 478 |
-
},
|
| 479 |
-
{
|
| 480 |
-
"cell_type": "code",
|
| 481 |
-
"execution_count": null,
|
| 482 |
-
"id": "33b24e85",
|
| 483 |
-
"metadata": {
|
| 484 |
-
"execution": {
|
| 485 |
-
"iopub.execute_input": "2026-09-27T13:37:58.383300Z",
|
| 486 |
-
"iopub.status.busy": "2026-09-27T13:37:58.383300Z",
|
| 487 |
-
"iopub.status.idle": "2026-09-27T13:37:58.405339Z",
|
| 488 |
-
"shell.execute_reply": "2026-09-27T13:37:58.405339Z"
|
| 489 |
-
}
|
| 490 |
-
},
|
| 491 |
"outputs": [],
|
| 492 |
"source": [
|
| 493 |
-
"
|
| 494 |
-
"
|
| 495 |
-
"
|
| 496 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 497 |
]
|
| 498 |
},
|
| 499 |
{
|
| 500 |
"cell_type": "markdown",
|
| 501 |
-
"id": "
|
| 502 |
"metadata": {},
|
| 503 |
"source": [
|
| 504 |
-
"
|
| 505 |
-
"\n",
|
| 506 |
-
"**Comment:** Layer 16 reached 98.21% balanced accuracy (31/32 correct predictions), falling to 93.75% when version 2 was excluded and the probes refitted. Layer 20 led that sensitivity analysis at 95.83%. Every tested layer and the pixel baseline had AUC 1.0 within each held-out family. Thus layer 16 was a useful working choice, not an independently confirmed optimum.\n",
|
| 507 |
"\n",
|
| 508 |
-
"
|
| 509 |
]
|
| 510 |
},
|
| 511 |
{
|
| 512 |
"cell_type": "code",
|
| 513 |
"execution_count": null,
|
| 514 |
-
"id": "
|
| 515 |
-
"metadata": {
|
| 516 |
-
"execution": {
|
| 517 |
-
"iopub.execute_input": "2026-09-27T13:37:58.406566Z",
|
| 518 |
-
"iopub.status.busy": "2026-09-27T13:37:58.406566Z",
|
| 519 |
-
"iopub.status.idle": "2026-09-27T13:37:58.414226Z",
|
| 520 |
-
"shell.execute_reply": "2026-09-27T13:37:58.414226Z"
|
| 521 |
-
}
|
| 522 |
-
},
|
| 523 |
-
"outputs": [],
|
| 524 |
-
"source": [
|
| 525 |
-
"distance = csv('stored_layers_16_22/distance_order_correlations.csv')\n",
|
| 526 |
-
"display(distance.query('layer == 16').groupby('exclude_2frame')[\n",
|
| 527 |
-
" 'spearman_disruption_vs_distance'].mean().rename('Mean Spearman rho').to_frame())"
|
| 528 |
-
]
|
| 529 |
-
},
|
| 530 |
-
{
|
| 531 |
-
"cell_type": "markdown",
|
| 532 |
-
"id": "24492faf",
|
| 533 |
"metadata": {},
|
| 534 |
-
"source": [
|
| 535 |
-
"## 6. Does reversing a coherent movement confuse the existing probe?\n",
|
| 536 |
-
"\n",
|
| 537 |
-
"We froze the original binary probe, reproduced its earlier logits, and reversed the four inferred intact clips. No reversed clip entered this probe's training. The control is useful because dragging and rotation can remain coherent backward."
|
| 538 |
-
]
|
| 539 |
-
},
|
| 540 |
-
{
|
| 541 |
-
"cell_type": "code",
|
| 542 |
-
"execution_count": null,
|
| 543 |
-
"id": "6920e066",
|
| 544 |
-
"metadata": {
|
| 545 |
-
"execution": {
|
| 546 |
-
"iopub.execute_input": "2026-09-27T13:37:58.416233Z",
|
| 547 |
-
"iopub.status.busy": "2026-09-27T13:37:58.416233Z",
|
| 548 |
-
"iopub.status.idle": "2026-09-27T13:37:58.429119Z",
|
| 549 |
-
"shell.execute_reply": "2026-09-27T13:37:58.429119Z"
|
| 550 |
-
}
|
| 551 |
-
},
|
| 552 |
"outputs": [],
|
| 553 |
"source": [
|
| 554 |
-
"
|
| 555 |
-
"
|
| 556 |
-
"
|
| 557 |
-
"
|
| 558 |
-
|
| 559 |
-
|
| 560 |
-
|
| 561 |
-
|
| 562 |
-
|
| 563 |
-
|
| 564 |
-
|
| 565 |
-
"
|
| 566 |
-
"\n",
|
| 567 |
-
"
|
| 568 |
-
"\n",
|
| 569 |
-
"
|
| 570 |
-
"\n",
|
| 571 |
-
"
|
|
|
|
| 572 |
]
|
| 573 |
},
|
| 574 |
{
|
| 575 |
"cell_type": "markdown",
|
| 576 |
-
"id": "
|
| 577 |
"metadata": {},
|
| 578 |
"source": [
|
| 579 |
-
"
|
| 580 |
-
"\n",
|
| 581 |
-
"$$\n",
|
| 582 |
-
"\\mathcal L(w)=\\operatorname{mean}_{(i,j)}\\log(1+e^{-w^\\top(z_i-z_j)})\n",
|
| 583 |
-
" +\\tfrac12\\|w\\|^2\n",
|
| 584 |
-
" +\\operatorname{mean}_{v}\\big[w^\\top(z_v-z_{v^R})\\big]^2.\n",
|
| 585 |
-
"$$\n",
|
| 586 |
"\n",
|
| 587 |
-
"
|
| 588 |
]
|
| 589 |
},
|
| 590 |
{
|
| 591 |
"cell_type": "code",
|
| 592 |
"execution_count": null,
|
| 593 |
-
"id": "
|
| 594 |
-
"metadata": {
|
| 595 |
-
"execution": {
|
| 596 |
-
"iopub.execute_input": "2026-09-27T13:37:58.430130Z",
|
| 597 |
-
"iopub.status.busy": "2026-09-27T13:37:58.430130Z",
|
| 598 |
-
"iopub.status.idle": "2026-09-27T13:37:58.440024Z",
|
| 599 |
-
"shell.execute_reply": "2026-09-27T13:37:58.440024Z"
|
| 600 |
-
}
|
| 601 |
-
},
|
| 602 |
-
"outputs": [],
|
| 603 |
-
"source": [
|
| 604 |
-
"graded = csv('layer16_probe_validation/graded_summary.csv')\n",
|
| 605 |
-
"display(graded[['method', 'evaluation', 'pairwise_accuracy', 'spearman_mean_by_level',\n",
|
| 606 |
-
" 'spearman_shuffled_levels', 'intact_auc']].round(4))\n",
|
| 607 |
-
"display(csv('layer16_probe_validation/graded_reversal_summary.csv').round(4))"
|
| 608 |
-
]
|
| 609 |
-
},
|
| 610 |
-
{
|
| 611 |
-
"cell_type": "markdown",
|
| 612 |
-
"id": "f96857eb",
|
| 613 |
"metadata": {},
|
| 614 |
-
"source": [
|
| 615 |
-
"> **Original reference run:** numerical commentary below describes the earlier local run. Generated tables/plots show this Colab run; compare them in section D.\n",
|
| 616 |
-
"\n",
|
| 617 |
-
"**Comment:** On new held-out templates, layer 16 ranked levels correctly 98.98% of the time; the pixel-only probe reached 100%. Reversal regularization slightly reduced the score gap without improving ranking. New permutations test template dependence, but they do not add new actors or scenes. The original stored-version evaluation excluded faulty version 2."
|
| 618 |
-
]
|
| 619 |
-
},
|
| 620 |
-
{
|
| 621 |
-
"cell_type": "markdown",
|
| 622 |
-
"id": "5c2cc2e3",
|
| 623 |
-
"metadata": {},
|
| 624 |
-
"source": [
|
| 625 |
-
"## 8. Outside stimuli: frozen transfer to IntPhys2\n",
|
| 626 |
-
"\n",
|
| 627 |
-
"We applied the already fitted MAT readouts to the complete selected IntPhys2 continuity subset: **240 clips, 60 scenes, 120 native possible/impossible pairs**, across eight task families. No IntPhys2 labels trained or calibrated a probe. The two MAT heads were averaged using their original sign.\n",
|
| 628 |
-
"\n",
|
| 629 |
-
"This is a harder test of the readout's scope: object continuity violations are different from deliberately shuffled video. Each clip is sampled to 90 frames across roughly 10.6–14.6 seconds, whereas the MAT clips cover about three seconds under the assumed preview rate. Domain and time sampling are additional changes."
|
| 630 |
-
]
|
| 631 |
-
},
|
| 632 |
-
{
|
| 633 |
-
"cell_type": "code",
|
| 634 |
-
"execution_count": null,
|
| 635 |
-
"id": "802a9302",
|
| 636 |
-
"metadata": {
|
| 637 |
-
"execution": {
|
| 638 |
-
"iopub.execute_input": "2026-09-27T13:37:58.441036Z",
|
| 639 |
-
"iopub.status.busy": "2026-09-27T13:37:58.441036Z",
|
| 640 |
-
"iopub.status.idle": "2026-09-27T13:37:58.471684Z",
|
| 641 |
-
"shell.execute_reply": "2026-09-27T13:37:58.470592Z"
|
| 642 |
-
}
|
| 643 |
-
},
|
| 644 |
"outputs": [],
|
| 645 |
"source": [
|
| 646 |
-
"
|
| 647 |
-
"
|
| 648 |
-
"
|
| 649 |
-
"
|
| 650 |
-
"\n",
|
| 651 |
-
"
|
| 652 |
-
"
|
| 653 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 654 |
]
|
| 655 |
},
|
| 656 |
{
|
| 657 |
"cell_type": "markdown",
|
| 658 |
-
"id": "
|
| 659 |
"metadata": {},
|
| 660 |
"source": [
|
| 661 |
-
"
|
| 662 |
-
"\n",
|
| 663 |
-
"**Comment:** The graded MAT readout preferred the possible event in **41/120 pairs (34.17%)**, versus **57/120 (47.5%)** for negative pixel MAE. We do not flip the score's sign after seeing this result. The transfer failed under the chosen readout and protocol; this does not show that the full layer contains no physical information.\n",
|
| 664 |
"\n",
|
| 665 |
-
"
|
| 666 |
]
|
| 667 |
},
|
| 668 |
{
|
| 669 |
"cell_type": "code",
|
| 670 |
"execution_count": null,
|
| 671 |
-
"id": "
|
| 672 |
-
"metadata": {
|
| 673 |
-
"execution": {
|
| 674 |
-
"iopub.execute_input": "2026-09-27T13:37:58.473694Z",
|
| 675 |
-
"iopub.status.busy": "2026-09-27T13:37:58.472698Z",
|
| 676 |
-
"iopub.status.idle": "2026-09-27T13:37:58.488186Z",
|
| 677 |
-
"shell.execute_reply": "2026-09-27T13:37:58.488186Z"
|
| 678 |
-
}
|
| 679 |
-
},
|
| 680 |
-
"outputs": [],
|
| 681 |
-
"source": [
|
| 682 |
-
"display(physical.query(\"scope == 'control_scenes' and method in ['graded_ensemble', 'binary_ensemble', 'negative_pixel_mae']\")\n",
|
| 683 |
-
" .pivot(index='method', columns='input_condition', values='matched_pair_accuracy').mul(100).round(2))\n",
|
| 684 |
-
"display(Image(filename=str(BASE / 'external_intphys2/external_results.png'), width=900))"
|
| 685 |
-
]
|
| 686 |
-
},
|
| 687 |
-
{
|
| 688 |
-
"cell_type": "markdown",
|
| 689 |
-
"id": "c97e365f",
|
| 690 |
"metadata": {},
|
| 691 |
-
"source": [
|
| 692 |
-
"## 9. A broader controlled test: 100 UCF source groups\n",
|
| 693 |
-
"\n",
|
| 694 |
-
"We selected one clip from each of 100 source groups, ten per action, from the pinned UCF101 subset. A central window supplies 64 distinct sampled frames. The core conditions retain blocks of 1, 4, 8 or 16 frames, plus intact 64, in both directions. There are five source folds, with all derivatives of a source kept together. Core shuffle templates are disjoint across those source folds. A separate evaluation leaves an entire action category out.\n",
|
| 695 |
-
"\n",
|
| 696 |
-
"Layer-16, pixel/motion, and joint readouts use the same ranking objective. Controls include 21 pixel/motion summaries, a fixed nonlinear regressor on those summaries, negative mean pixel change, and the earlier MAT readout transferred without refitting. The predictor remains unused.\n",
|
| 697 |
-
"\n",
|
| 698 |
-
"**Why this design?** Same-image permutations control static content. Source grouping prevents nearly identical variants from crossing training and test splits. New action categories ask a stronger transfer question. Pixel baselines check whether simple discontinuity already explains the labels."
|
| 699 |
-
]
|
| 700 |
-
},
|
| 701 |
-
{
|
| 702 |
-
"cell_type": "code",
|
| 703 |
-
"execution_count": null,
|
| 704 |
-
"id": "120e7765",
|
| 705 |
-
"metadata": {
|
| 706 |
-
"execution": {
|
| 707 |
-
"iopub.execute_input": "2026-09-27T13:37:58.490201Z",
|
| 708 |
-
"iopub.status.busy": "2026-09-27T13:37:58.490201Z",
|
| 709 |
-
"iopub.status.idle": "2026-09-27T13:37:58.511743Z",
|
| 710 |
-
"shell.execute_reply": "2026-09-27T13:37:58.511743Z"
|
| 711 |
-
}
|
| 712 |
-
},
|
| 713 |
"outputs": [],
|
| 714 |
"source": [
|
| 715 |
-
"
|
| 716 |
-
"
|
| 717 |
-
"
|
| 718 |
-
"
|
| 719 |
-
"
|
| 720 |
-
"
|
| 721 |
-
"
|
| 722 |
-
"
|
| 723 |
-
"
|
| 724 |
-
"
|
| 725 |
-
"
|
| 726 |
-
"
|
| 727 |
-
"assert
|
| 728 |
-
"(
|
| 729 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 730 |
]
|
| 731 |
},
|
| 732 |
{
|
| 733 |
"cell_type": "markdown",
|
| 734 |
-
"id": "
|
| 735 |
"metadata": {},
|
| 736 |
"source": [
|
| 737 |
-
"##
|
| 738 |
"\n",
|
| 739 |
-
"
|
| 740 |
]
|
| 741 |
},
|
| 742 |
{
|
| 743 |
"cell_type": "code",
|
| 744 |
"execution_count": null,
|
| 745 |
-
"id": "
|
| 746 |
-
"metadata": {
|
| 747 |
-
"execution": {
|
| 748 |
-
"iopub.execute_input": "2026-09-27T13:37:58.512749Z",
|
| 749 |
-
"iopub.status.busy": "2026-09-27T13:37:58.512749Z",
|
| 750 |
-
"iopub.status.idle": "2026-09-27T13:37:58.559303Z",
|
| 751 |
-
"shell.execute_reply": "2026-09-27T13:37:58.559303Z"
|
| 752 |
-
}
|
| 753 |
-
},
|
| 754 |
-
"outputs": [],
|
| 755 |
-
"source": [
|
| 756 |
-
"methods = ['layer16', 'pixel_motion', 'joint', 'motion_nonlinear', 'negative_pixel_mae', 'old_mat_probe']\n",
|
| 757 |
-
"def ranking_rate(values):\n",
|
| 758 |
-
" i, j = np.triu_indices(len(values), k=1)\n",
|
| 759 |
-
" gaps = np.asarray(values)[j] - np.asarray(values)[i]\n",
|
| 760 |
-
" return np.where(gaps > 1e-12, 1, np.where(gaps < -1e-12, 0, .5)).mean()\n",
|
| 761 |
-
"\n",
|
| 762 |
-
"ranked = core.groupby(['source_id', 'direction'])[methods].agg(ranking_rate)\n",
|
| 763 |
-
"recomputed = ranked.groupby('source_id').mean().mean()\n",
|
| 764 |
-
"broad_summary = csv('broad_layer16/summary_metrics.csv')\n",
|
| 765 |
-
"recorded = broad_summary.query(\"scheme == 'source_folds' and direction == 'both' and metric == 'rank_accuracy'\")\n",
|
| 766 |
-
"assert np.allclose(recomputed, recorded.set_index('method').loc[methods, 'mean'])\n",
|
| 767 |
-
"display(recomputed.mul(100).round(3).rename('Core pair ranking (%)').to_frame())"
|
| 768 |
-
]
|
| 769 |
-
},
|
| 770 |
-
{
|
| 771 |
-
"cell_type": "markdown",
|
| 772 |
-
"id": "d962ebcc",
|
| 773 |
"metadata": {},
|
| 774 |
-
"source": [
|
| 775 |
-
"> **Original reference run:** numerical commentary below describes the earlier local run. Generated tables/plots show this Colab run; compare them in section D.\n",
|
| 776 |
-
"\n",
|
| 777 |
-
"**Comment:** Layer 16 achieves **99.95% pair ranking**, but negative pixel MAE reaches **100%**. The manipulation clearly transfers to new sources; superiority over simple pixel change is not established. The same layer-16 pair ranking holds in the action-holdout analysis.\n",
|
| 778 |
-
"\n",
|
| 779 |
-
"Pair ranking is not isolated-clip classification. A fixed score threshold of 0.5 gives only **68.125% balanced accuracy** for intact versus shuffled. It is wrong to describe the 99.95% result as 99.95% standalone coherence classification."
|
| 780 |
-
]
|
| 781 |
-
},
|
| 782 |
-
{
|
| 783 |
-
"cell_type": "code",
|
| 784 |
-
"execution_count": null,
|
| 785 |
-
"id": "52308589",
|
| 786 |
-
"metadata": {
|
| 787 |
-
"execution": {
|
| 788 |
-
"iopub.execute_input": "2026-09-27T13:37:58.561589Z",
|
| 789 |
-
"iopub.status.busy": "2026-09-27T13:37:58.561589Z",
|
| 790 |
-
"iopub.status.idle": "2026-09-27T13:37:58.567953Z",
|
| 791 |
-
"shell.execute_reply": "2026-09-27T13:37:58.567953Z"
|
| 792 |
-
}
|
| 793 |
-
},
|
| 794 |
"outputs": [],
|
| 795 |
"source": [
|
| 796 |
-
"
|
| 797 |
-
"
|
| 798 |
-
"
|
| 799 |
-
"
|
| 800 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 801 |
]
|
| 802 |
},
|
| 803 |
{
|
| 804 |
"cell_type": "markdown",
|
| 805 |
-
"id": "
|
| 806 |
"metadata": {},
|
| 807 |
"source": [
|
| 808 |
-
"
|
| 809 |
-
"\n",
|
| 810 |
-
"### Did matching pixel change remove the confound?\n",
|
| 811 |
-
"\n",
|
| 812 |
-
"Only five sources yielded an intact/shuffled pair within 5% on both average MAE and global RMS, too few for the intended strong comparison. A declared amendment therefore compared block-16 with block-8 permutations of the same images, chosen using pixels only. **38 sources** met the 5% tolerance (91 met 10%). The amendment was fixed before probe outcomes.\n",
|
| 813 |
-
"\n",
|
| 814 |
-
"Matching magnitudes approximately does not remove which member has slightly lower pixel change. The next table makes that residual cue visible."
|
| 815 |
-
]
|
| 816 |
-
},
|
| 817 |
-
{
|
| 818 |
-
"cell_type": "code",
|
| 819 |
-
"execution_count": null,
|
| 820 |
-
"id": "b0320ff5",
|
| 821 |
-
"metadata": {
|
| 822 |
-
"execution": {
|
| 823 |
-
"iopub.execute_input": "2026-09-27T13:37:58.569959Z",
|
| 824 |
-
"iopub.status.busy": "2026-09-27T13:37:58.569959Z",
|
| 825 |
-
"iopub.status.idle": "2026-09-27T13:37:58.580757Z",
|
| 826 |
-
"shell.execute_reply": "2026-09-27T13:37:58.580757Z"
|
| 827 |
-
}
|
| 828 |
-
},
|
| 829 |
-
"outputs": [],
|
| 830 |
-
"source": [
|
| 831 |
-
"matched = broad_summary.query(\"scheme == 'source_folds' and direction == 'both' and metric == 'matched_levels_5pct_accuracy'\")\n",
|
| 832 |
-
"display(matched[['method', 'n_sources', 'mean', 'ci95_low', 'ci95_high']].round(4))\n",
|
| 833 |
-
"added = csv('broad_layer16/paired_comparisons.csv')\n",
|
| 834 |
-
"display(added.query(\"scheme == 'source_folds' and metric == 'matched_levels_5pct_accuracy' and comparison in ['joint minus pixel_motion', 'layer16 minus negative_pixel_mae']\")\n",
|
| 835 |
-
" [['comparison', 'n_sources', 'mean_difference', 'ci95_low', 'ci95_high']].round(4))"
|
| 836 |
-
]
|
| 837 |
-
},
|
| 838 |
-
{
|
| 839 |
-
"cell_type": "markdown",
|
| 840 |
-
"id": "ebd04b6e",
|
| 841 |
-
"metadata": {},
|
| 842 |
-
"source": [
|
| 843 |
-
"> **Original reference run:** numerical commentary below describes the earlier local run. Generated tables/plots show this Colab run; compare them in section D.\n",
|
| 844 |
-
"\n",
|
| 845 |
-
"**Comment:** Layer 16 scores **78.95%** on the strict matched pairs; negative MAE still scores **97.37%**. Matching did not solve the confound. Adding layer 16 to the linear pixel/motion readout has a paired interval including zero. We have not demonstrated an added coherence signal beyond the strongest tested simple baseline.\n",
|
| 846 |
-
"\n",
|
| 847 |
-
"Bootstrap intervals resample source groups within actions, keeping methods paired. They condition on the fitted folds and selected actions; they do not include full retraining uncertainty or sampling entirely new action families. An all-success sample can have a zero-width bootstrap interval without implying population certainty."
|
| 848 |
-
]
|
| 849 |
-
},
|
| 850 |
-
{
|
| 851 |
-
"cell_type": "markdown",
|
| 852 |
-
"id": "87ddfdbc",
|
| 853 |
-
"metadata": {},
|
| 854 |
-
"source": [
|
| 855 |
-
"## 10. Arrow of time: can the layer decode stored playback direction?\n",
|
| 856 |
-
"\n",
|
| 857 |
-
"This is the new experiment. We reuse the same 100 UCF sources and intact 64-frame inputs, each forward and reversed. A fixed `StandardScaler` + L2 logistic regression (`C=1`) trains on intact direction labels only. There are 80 training and 20 held-out source pairs per primary fold; action holdout trains on 90 and evaluates ten pairs.\n",
|
| 858 |
-
"\n",
|
| 859 |
-
"The primary representation is the same 1,024-dimensional pooled layer-16 vector. A secondary probe concatenates eight ordered temporal bins (8,192 values). Baselines use endpoint RGB differences, ordered low-resolution RGB bins, 21 pixel/motion statistics, and exactly reversal-invariant pixels. We copy mathematically symmetric statistics exactly within each pair so floating-point summation order cannot become a fake direction cue.\n",
|
| 860 |
-
"\n",
|
| 861 |
-
"$$\n",
|
| 862 |
-
"\\text{pair score}=\\mathbb{1}[s(v)>s(v^R)]\\quad\\text{with ties worth }1/2.\n",
|
| 863 |
-
"$$\n",
|
| 864 |
-
"\n",
|
| 865 |
-
"The operational target is stored playback direction. These UCF actions were not screened by people for a unique physical arrow; many motions can be reversible. The task is motivated by [Learning and Using the Arrow of Time](https://openaccess.thecvf.com/content_cvpr_2018/papers/Wei_Learning_and_Using_CVPR_2018_paper.pdf), but this is not a reproduction of its benchmark."
|
| 866 |
-
]
|
| 867 |
-
},
|
| 868 |
-
{
|
| 869 |
-
"cell_type": "code",
|
| 870 |
-
"execution_count": null,
|
| 871 |
-
"id": "ee3fccd4",
|
| 872 |
-
"metadata": {
|
| 873 |
-
"execution": {
|
| 874 |
-
"iopub.execute_input": "2026-09-27T13:37:58.581762Z",
|
| 875 |
-
"iopub.status.busy": "2026-09-27T13:37:58.581762Z",
|
| 876 |
-
"iopub.status.idle": "2026-09-27T13:37:58.600314Z",
|
| 877 |
-
"shell.execute_reply": "2026-09-27T13:37:58.600314Z"
|
| 878 |
-
}
|
| 879 |
-
},
|
| 880 |
-
"outputs": [],
|
| 881 |
-
"source": [
|
| 882 |
-
"aot = csv('temporal_diagnostics/aot_predictions.csv')\n",
|
| 883 |
-
"pairs = aot.pivot(index=['scheme', 'method', 'source_id'], columns='direction', values='logit')\n",
|
| 884 |
-
"gap = pairs.forward - pairs.reverse\n",
|
| 885 |
-
"pairs['correct'] = np.where(gap > 1e-10, 1, np.where(gap < -1e-10, 0, .5))\n",
|
| 886 |
-
"display(pairs.groupby(['method', 'scheme']).correct.mean().unstack().mul(100).round(1))\n",
|
| 887 |
-
"display(Image(filename=str(BASE / 'temporal_diagnostics/arrow_of_time.png'), width=1000))"
|
| 888 |
-
]
|
| 889 |
-
},
|
| 890 |
-
{
|
| 891 |
-
"cell_type": "markdown",
|
| 892 |
-
"id": "181d4e40",
|
| 893 |
-
"metadata": {},
|
| 894 |
-
"source": [
|
| 895 |
-
"> **Original reference run:** numerical commentary below describes the earlier local run. Generated tables/plots show this Colab run; compare them in section D.\n",
|
| 896 |
-
"\n",
|
| 897 |
-
"**Comment:** The pooled direction probe achieves **73/100 source pairs** (95% CI 65–81%) but **49/100** when an action category is held out (40–58%). The data support action-dependent direction cues, with no reliable transfer to new action categories. The temporal-bin probe achieves 56% and 43%, respectively. Its higher feature count changes capacity and regularization, so this does not isolate a causal benefit of pooling.\n",
|
| 898 |
-
"\n",
|
| 899 |
-
"Again, ranking and thresholding differ: pooled-layer individual-clip balanced accuracy is **54%** under source holdout and **46%** under action holdout. The 73% result is a comparison between matched forward/reverse members."
|
| 900 |
-
]
|
| 901 |
-
},
|
| 902 |
-
{
|
| 903 |
-
"cell_type": "code",
|
| 904 |
-
"execution_count": null,
|
| 905 |
-
"id": "a0197e0c",
|
| 906 |
-
"metadata": {
|
| 907 |
-
"execution": {
|
| 908 |
-
"iopub.execute_input": "2026-09-27T13:37:58.600314Z",
|
| 909 |
-
"iopub.status.busy": "2026-09-27T13:37:58.600314Z",
|
| 910 |
-
"iopub.status.idle": "2026-09-27T13:37:58.614501Z",
|
| 911 |
-
"shell.execute_reply": "2026-09-27T13:37:58.614501Z"
|
| 912 |
-
}
|
| 913 |
-
},
|
| 914 |
-
"outputs": [],
|
| 915 |
-
"source": [
|
| 916 |
-
"aot_summary = csv('temporal_diagnostics/aot_summary.csv')\n",
|
| 917 |
-
"display(aot_summary.query(\"method == 'layer16_pooled' and metric in ['pair_accuracy', 'individual_accuracy']\")\n",
|
| 918 |
-
" [['scheme', 'metric', 'n_sources', 'mean', 'ci95_low', 'ci95_high']].round(3))\n",
|
| 919 |
-
"permutation = saved_json('temporal_diagnostics/permutation_result.json')\n",
|
| 920 |
-
"display(pd.Series(permutation, name='Primary label-swap test').to_frame())\n",
|
| 921 |
-
"display(Image(filename=str(BASE / 'temporal_diagnostics/direction_generalization.png'), width=1000))"
|
| 922 |
-
]
|
| 923 |
-
},
|
| 924 |
-
{
|
| 925 |
-
"cell_type": "markdown",
|
| 926 |
-
"id": "bcbfca5f",
|
| 927 |
-
"metadata": {},
|
| 928 |
-
"source": [
|
| 929 |
-
"> **Original reference run:** numerical commentary below describes the earlier local run. Generated tables/plots show this Colab run; compare them in section D.\n",
|
| 930 |
-
"\n",
|
| 931 |
-
"The primary label-swap test randomly flips each source's pair labels, refits all five probes, and repeats 100 times. The empirical one-sided **p = 1/101 ≈ 0.0099** is the smallest value resolvable with 100 permutations. This supports the source-holdout result, not action transfer. All other method comparisons and control families are exploratory.\n",
|
| 932 |
-
"\n",
|
| 933 |
-
"### The actual readout in a few lines\n",
|
| 934 |
-
"\n",
|
| 935 |
-
"Below we load the 200 saved intact embeddings and reproduce one primary fold. Scaling is fitted only on training sources. The held-out sources are asserted to be disjoint. The predictions must match the saved experiment before we interpret them."
|
| 936 |
-
]
|
| 937 |
-
},
|
| 938 |
-
{
|
| 939 |
-
"cell_type": "code",
|
| 940 |
-
"execution_count": null,
|
| 941 |
-
"id": "cd74c9c3",
|
| 942 |
-
"metadata": {
|
| 943 |
-
"execution": {
|
| 944 |
-
"iopub.execute_input": "2026-09-27T13:37:58.615505Z",
|
| 945 |
-
"iopub.status.busy": "2026-09-27T13:37:58.615505Z",
|
| 946 |
-
"iopub.status.idle": "2026-09-27T13:37:59.517734Z",
|
| 947 |
-
"shell.execute_reply": "2026-09-27T13:37:59.515701Z"
|
| 948 |
-
}
|
| 949 |
-
},
|
| 950 |
-
"outputs": [],
|
| 951 |
-
"source": [
|
| 952 |
-
"from sklearn.pipeline import make_pipeline\n",
|
| 953 |
-
"from sklearn.preprocessing import StandardScaler\n",
|
| 954 |
-
"from sklearn.linear_model import LogisticRegression\n",
|
| 955 |
-
"from scipy.optimize import OptimizeWarning\n",
|
| 956 |
-
"from threadpoolctl import threadpool_limits\n",
|
| 957 |
-
"import warnings\n",
|
| 958 |
-
"\n",
|
| 959 |
-
"intact_rows = aot.query(\"scheme == 'source_folds' and method == 'layer16_pooled'\").sort_values(['source_id', 'direction']).reset_index(drop=True)\n",
|
| 960 |
-
"def pooled_feature(row):\n",
|
| 961 |
-
" filename = f'{row.source_id}_intact_{row.direction}.npz'\n",
|
| 962 |
-
" with np.load(BASE / 'broad_layer16/features' / filename) as data: return data['feature']\n",
|
| 963 |
-
"X = np.stack([pooled_feature(row) for row in intact_rows.itertuples()]).astype(float)\n",
|
| 964 |
-
"y = intact_rows.original_forward.to_numpy()\n",
|
| 965 |
-
"test = intact_rows.fold.eq(0).to_numpy()\n",
|
| 966 |
-
"assert not set(intact_rows.loc[test, 'source_id']) & set(intact_rows.loc[~test, 'source_id'])"
|
| 967 |
-
]
|
| 968 |
-
},
|
| 969 |
-
{
|
| 970 |
-
"cell_type": "code",
|
| 971 |
-
"execution_count": null,
|
| 972 |
-
"id": "82d664c8",
|
| 973 |
-
"metadata": {
|
| 974 |
-
"execution": {
|
| 975 |
-
"iopub.execute_input": "2026-09-27T13:37:59.521732Z",
|
| 976 |
-
"iopub.status.busy": "2026-09-27T13:37:59.520738Z",
|
| 977 |
-
"iopub.status.idle": "2026-09-27T13:37:59.680084Z",
|
| 978 |
-
"shell.execute_reply": "2026-09-27T13:37:59.679076Z"
|
| 979 |
-
}
|
| 980 |
-
},
|
| 981 |
-
"outputs": [],
|
| 982 |
-
"source": [
|
| 983 |
-
"probe = make_pipeline(StandardScaler(), LogisticRegression(C=1, class_weight='balanced',\n",
|
| 984 |
-
" solver='lbfgs', max_iter=5000, tol=1e-7, random_state=SEED))\n",
|
| 985 |
-
"with threadpool_limits(4), warnings.catch_warnings():\n",
|
| 986 |
-
" warnings.filterwarnings('ignore', message='Unknown solver options: iprint', category=OptimizeWarning)\n",
|
| 987 |
-
" probe.fit(X[~test], y[~test])\n",
|
| 988 |
-
"error = np.max(np.abs(probe.decision_function(X[test]) - intact_rows.loc[test, 'logit']))\n",
|
| 989 |
-
"assert error < 1e-5, f'Predictions changed: {error}'\n",
|
| 990 |
-
"print(f'Reproduced one held-out direction fold; maximum logit difference = {error:.2g}')"
|
| 991 |
-
]
|
| 992 |
-
},
|
| 993 |
-
{
|
| 994 |
-
"cell_type": "markdown",
|
| 995 |
-
"id": "bdaac30f",
|
| 996 |
-
"metadata": {},
|
| 997 |
-
"source": [
|
| 998 |
-
"## 11. Related temporal controls\n",
|
| 999 |
-
"\n",
|
| 1000 |
-
"The new families were specified before their outcomes. They test how the two different heads respond outside their training manipulations. Each condition is also fully reversed; all transformations come from the same 100 sources.\n",
|
| 1001 |
-
"\n",
|
| 1002 |
-
"| Manipulation | Purpose | Interpretation limit |\n",
|
| 1003 |
-
"|---|---|---|\n",
|
| 1004 |
-
"| Reverse within 2-frame blocks | Change order within encoder tubelets, retain coarse chronology | Also changes local motion |\n",
|
| 1005 |
-
"| Reverse within 8- or 16-frame blocks | Retain blocks but reverse their internal motion | No human coherence target |\n",
|
| 1006 |
-
"| Circular shift by 32 frames | Change starting phase, introduce one wrap seam | Not guaranteed equally coherent |\n",
|
| 1007 |
-
"| Repeat the middle frame | Remove motion | Static does not mean incoherent |\n",
|
| 1008 |
-
"| Palindrome: 0…31, 31…0 | Make input identical to its full reversal | Changes the frame multiset |\n",
|
| 1009 |
-
"| Existing block shuffles | Remove order at several scales | New to the direction head, seen in order-head training |\n",
|
| 1010 |
-
"\n",
|
| 1011 |
-
"Static and palindrome pairs are direction-information nulls: identical input must give identical scores up to numerical rounding. Inputs and features were checked for exact equality; batched dot products can differ by about 10⁻¹⁴. Our declared tie tolerance is 10⁻¹⁰. On other transformed clips, “forward” identifies the constructed pair member, not verified natural physical direction. We therefore call the result **forward-member preference**, rather than natural arrow-of-time accuracy."
|
| 1012 |
-
]
|
| 1013 |
-
},
|
| 1014 |
-
{
|
| 1015 |
-
"cell_type": "code",
|
| 1016 |
-
"execution_count": null,
|
| 1017 |
-
"id": "52b25a94",
|
| 1018 |
-
"metadata": {
|
| 1019 |
-
"execution": {
|
| 1020 |
-
"iopub.execute_input": "2026-09-27T13:37:59.680084Z",
|
| 1021 |
-
"iopub.status.busy": "2026-09-27T13:37:59.680084Z",
|
| 1022 |
-
"iopub.status.idle": "2026-09-27T13:37:59.754149Z",
|
| 1023 |
-
"shell.execute_reply": "2026-09-27T13:37:59.753115Z"
|
| 1024 |
-
}
|
| 1025 |
-
},
|
| 1026 |
-
"outputs": [],
|
| 1027 |
-
"source": [
|
| 1028 |
-
"control_predictions = csv('temporal_diagnostics/direction_control_predictions.csv')\n",
|
| 1029 |
-
"control_pairs = control_predictions.pivot(index=['scheme', 'method', 'condition', 'source_id'],\n",
|
| 1030 |
-
" columns='direction', values='logit')\n",
|
| 1031 |
-
"null_pairs = control_pairs.reset_index().query(\"condition in ['repeat_middle', 'palindrome']\")\n",
|
| 1032 |
-
"assert np.allclose(null_pairs.forward, null_pairs.reverse, atol=1e-10, rtol=0)\n",
|
| 1033 |
-
"print(f'Maximum null-pair logit gap: {np.max(np.abs(null_pairs.forward-null_pairs.reverse)):.2g}')\n",
|
| 1034 |
-
"display(pd.DataFrame(saved_json('temporal_diagnostics/null_reproduction.json')))\n",
|
| 1035 |
-
"control_summary = csv('temporal_diagnostics/direction_controls_summary.csv')\n",
|
| 1036 |
-
"display(control_summary.query(\"scheme == 'source_folds' and metric == 'pair_accuracy' and method in ['layer16_pooled', 'layer16_temporal']\")\n",
|
| 1037 |
-
" .pivot(index='condition', columns='method', values='mean').mul(100).round(1))"
|
| 1038 |
-
]
|
| 1039 |
-
},
|
| 1040 |
-
{
|
| 1041 |
-
"cell_type": "markdown",
|
| 1042 |
-
"id": "b382f7c3",
|
| 1043 |
-
"metadata": {},
|
| 1044 |
-
"source": [
|
| 1045 |
-
"> **Original reference run:** numerical commentary below describes the earlier local run. Generated tables/plots show this Colab run; compare them in section D.\n",
|
| 1046 |
-
"\n",
|
| 1047 |
-
"We also reversed the eight feature bins, or replaced every bin by the temporal mean, while keeping the saved temporal direction-head weights. These are interventions on features, not rendered videos. Temporal pooling can retain contextual order information; averaging bins does not necessarily delete every order cue encoded in each feature.\n",
|
| 1048 |
-
"\n",
|
| 1049 |
-
"For source holdout, the temporal-bin head scored 56% on intact inputs, 48% after bin reversal, and 67% after repeating the temporal mean. These exploratory results do not support the simple assumption that preserving explicit feature-bin order must improve this small-sample readout.\n",
|
| 1050 |
-
"\n",
|
| 1051 |
-
"### How does the existing order probe respond?\n",
|
| 1052 |
-
"\n",
|
| 1053 |
-
"The earlier UCF order probe receives these new inputs without retraining. Below are its mean scores, averaged across both directions and then sources. Its training anchors are 0 for full shuffle and 1 for intact, not perceptual endpoints. The baseline and joint curves use their own training anchors."
|
| 1054 |
-
]
|
| 1055 |
-
},
|
| 1056 |
-
{
|
| 1057 |
-
"cell_type": "code",
|
| 1058 |
-
"execution_count": null,
|
| 1059 |
-
"id": "14dba442",
|
| 1060 |
-
"metadata": {
|
| 1061 |
-
"execution": {
|
| 1062 |
-
"iopub.execute_input": "2026-09-27T13:37:59.756140Z",
|
| 1063 |
-
"iopub.status.busy": "2026-09-27T13:37:59.756140Z",
|
| 1064 |
-
"iopub.status.idle": "2026-09-27T13:37:59.773614Z",
|
| 1065 |
-
"shell.execute_reply": "2026-09-27T13:37:59.773053Z"
|
| 1066 |
-
}
|
| 1067 |
-
},
|
| 1068 |
-
"outputs": [],
|
| 1069 |
-
"source": [
|
| 1070 |
-
"coherence = csv('temporal_diagnostics/coherence_control_summary.csv')\n",
|
| 1071 |
-
"display(coherence.query(\"scheme == 'source_folds' and method == 'layer16' and metric in ['score', 'delta_from_intact']\")\n",
|
| 1072 |
-
" .pivot(index='condition', columns='metric', values='mean').round(3))\n",
|
| 1073 |
-
"display(Image(filename=str(BASE / 'temporal_diagnostics/temporal_controls.png'), width=1050))"
|
| 1074 |
-
]
|
| 1075 |
-
},
|
| 1076 |
-
{
|
| 1077 |
-
"cell_type": "markdown",
|
| 1078 |
-
"id": "a502738a",
|
| 1079 |
-
"metadata": {},
|
| 1080 |
-
"source": [
|
| 1081 |
-
"> **Original reference run:** numerical commentary below describes the earlier local run. Generated tables/plots show this Colab run; compare them in section D.\n",
|
| 1082 |
-
"\n",
|
| 1083 |
-
"**Comment:** Interpret these scores as responses of a learned manipulation readout. Local reversals and shifts change more than one temporal property. Static and palindrome conditions have no assigned coherence label. The order head was explicitly trained for reversal consistency, whereas the direction head was trained to separate reversals; both can read different combinations of the same layer's features.\n",
|
| 1084 |
-
"\n",
|
| 1085 |
-
"The pooled direction head's forward-member preference drops from 73% intact to 61%, 48% and 35% under local reversal in blocks of 2, 8 and 16. Circular shifts retain 68%; full frame shuffling leaves 43%. These are descriptive responses to the manipulations, not correctness judgments about their physical arrow.\n",
|
| 1086 |
-
"\n",
|
| 1087 |
-
"The order head gives a repeated still frame a mean score of **1.076**, compared with **0.999** for intact video; the palindrome scores **0.908** and the circular shift **0.950**. This highlights that a high score does not require a progressing event. It fits the learned smoothness/order target, without validating perceived coherence.\n",
|
| 1088 |
-
"\n",
|
| 1089 |
-
"There are 2,200 diagnostic condition records and 1,000 new unique encoder inputs. The sample size for generalization is still 100 source groups. New transformations do not create new independent source videos."
|
| 1090 |
-
]
|
| 1091 |
-
},
|
| 1092 |
-
{
|
| 1093 |
-
"cell_type": "markdown",
|
| 1094 |
-
"id": "b93cce2a",
|
| 1095 |
-
"metadata": {},
|
| 1096 |
-
"source": [
|
| 1097 |
-
"> **Original reference run:** numerical commentary below describes the earlier local run. Generated tables/plots show this Colab run; compare them in section D.\n",
|
| 1098 |
-
"\n",
|
| 1099 |
-
"## 12. All evidence together\n",
|
| 1100 |
-
"\n",
|
| 1101 |
-
"| Evidence | Observed result | Supported conclusion |\n",
|
| 1102 |
-
"|---|---|---|\n",
|
| 1103 |
-
"| Initial final-layer pilot | Ranking better than threshold transfer; supplied cells were already shuffled | Additional-order sensitivity; corrected initial labels |\n",
|
| 1104 |
-
"| MAT layer sweep | Layer 16 BA 98.21%; 93.75% excluding anomalous version 2 | A useful exploratory layer on four related source variants |\n",
|
| 1105 |
-
"| Untrained reversal tolerance | 4/4 intact reversals accepted | Existing MAT binary probe tolerates these reversed motions |\n",
|
| 1106 |
-
"| New MAT templates | Layer 16 98.98% ranking; pixels 100% | Good manipulation/template decoding; pixel confounding remains |\n",
|
| 1107 |
-
"| Frozen IntPhys2 transfer | Layer 16 readout 34.17%; negative MAE 47.5% | No validated continuity/physics transfer |\n",
|
| 1108 |
-
"| UCF source/action transfer | Layer 16 99.95% ranking; negative MAE 100% | Order disruption generalizes beyond the original stimuli |\n",
|
| 1109 |
-
"| UCF matched levels | Layer 16 78.95%; negative MAE 97.37% | Approximate matching did not remove the pixel cue |\n",
|
| 1110 |
-
"| UCF fixed 0.5 threshold | Layer 16 68.125% balanced accuracy | Pair ranking is not a reliable universal classifier threshold |\n",
|
| 1111 |
-
"| Arrow of time, source holdout | Pooled layer 16 73%, CI 65–81%; permutation p ≈ .0099 | Direction cues accessible within represented actions |\n",
|
| 1112 |
-
"| Arrow of time, action holdout | Pooled layer 16 49%, CI 40–58% | Reliable direction transfer to new actions not established |\n",
|
| 1113 |
-
"| New transformations / nulls | Static order score 1.076 versus intact 0.999; null direction pairs 50% | High order score need not imply a progressing event |\n",
|
| 1114 |
-
"\n",
|
| 1115 |
-
"### What can we say about layer 16?\n",
|
| 1116 |
-
"\n",
|
| 1117 |
-
"**It contains information useful for reading out temporal order and some action-dependent playback direction. The present evidence does not establish a dedicated or general temporal-coherence feature.** The pixel ceiling, negative physical transfer, weak threshold transfer, and action-holdout direction failure all constrain the claim.\n",
|
| 1118 |
-
"\n",
|
| 1119 |
-
"The next substantive improvement would be independent sources with clearly interpretable temporal violations and stronger control of residual pixel/motion cues. A held-out set of physically irreversible events would test direction more cleanly. Human coherence validation remains deferred, as requested. We have not collected or imputed those ratings.\n",
|
| 1120 |
-
"\n",
|
| 1121 |
-
"### Shared limitations\n",
|
| 1122 |
-
"\n",
|
| 1123 |
-
"- Layer 16 was selected after exploratory results; it is fixed in the later studies but not an independently selected universal best layer.\n",
|
| 1124 |
-
"- MAT augmentation repeatedly uses four related source variants. UCF follow-ups repeatedly use the same 100 sources and ten actions. Encoder pretraining overlap is unknown.\n",
|
| 1125 |
-
"- Video domains, sampling spans and frame counts differ across studies. No negative transfer result isolates one cause.\n",
|
| 1126 |
-
"- Bootstrap intervals condition on fitted folds and sampled actions. Exploratory comparisons are not corrected confirmatory tests.\n",
|
| 1127 |
-
"- No readout was calibrated to human experience, and a probe weight is not a causal localization of a feature."
|
| 1128 |
-
]
|
| 1129 |
-
},
|
| 1130 |
-
{
|
| 1131 |
-
"cell_type": "markdown",
|
| 1132 |
-
"id": "fea732c5",
|
| 1133 |
-
"metadata": {},
|
| 1134 |
-
"source": [
|
| 1135 |
-
"> **Original reference run:** numerical commentary below describes the earlier local run. Generated tables/plots show this Colab run; compare them in section D.\n",
|
| 1136 |
-
"\n",
|
| 1137 |
-
"### Retained checks and supplementary pilot controls\n",
|
| 1138 |
-
"\n",
|
| 1139 |
-
"Checkpoint hashes, sequence indices, source-group splits, feature reproduction checks and readout weights are saved alongside the tables. The current extraction reproduced both pooled and temporal reference activations exactly. Static/palindrome prediction identity is checked above.\n",
|
| 1140 |
-
"\n",
|
| 1141 |
-
"The historical pilot also tried contextual-feature roughness and tested its fitted classifiers on other shuffle types and reversal. These results are retained below for completeness. A naive “rougher latent trajectory = less coherent” rule was not reliable: only about 21.9% of full shuffles increased that roughness. A contextualized token trajectory cannot be assumed to behave like raw pixel motion."
|
| 1142 |
-
]
|
| 1143 |
-
},
|
| 1144 |
-
{
|
| 1145 |
-
"cell_type": "code",
|
| 1146 |
-
"execution_count": null,
|
| 1147 |
-
"id": "93048822",
|
| 1148 |
-
"metadata": {
|
| 1149 |
-
"execution": {
|
| 1150 |
-
"iopub.execute_input": "2026-09-27T13:37:59.794801Z",
|
| 1151 |
-
"iopub.status.busy": "2026-09-27T13:37:59.794801Z",
|
| 1152 |
-
"iopub.status.idle": "2026-09-27T13:37:59.817297Z",
|
| 1153 |
-
"shell.execute_reply": "2026-09-27T13:37:59.817297Z"
|
| 1154 |
-
}
|
| 1155 |
-
},
|
| 1156 |
-
"outputs": [],
|
| 1157 |
-
"source": [
|
| 1158 |
-
"pilot_pairs = pd.read_csv(PILOT / 'paired_scores.csv')\n",
|
| 1159 |
-
"display(pilot_pairs.groupby(['condition', 'score']).fraction_shuffles_above_original.mean().round(3))\n",
|
| 1160 |
-
"transfer = pd.read_csv(PILOT / 'direction_and_block_transfer.csv')\n",
|
| 1161 |
-
"display(transfer.query(\"method == 'V-JEPA 2 pooled features'\").groupby(['trained_on', 'evaluated_condition'])\n",
|
| 1162 |
-
" .fraction_called_shuffled.mean().unstack().round(3))\n",
|
| 1163 |
-
"display(pd.DataFrame(saved_json('temporal_diagnostics/feature_reproduction.json')))"
|
| 1164 |
-
]
|
| 1165 |
-
},
|
| 1166 |
-
{
|
| 1167 |
-
"cell_type": "markdown",
|
| 1168 |
-
"id": "020a0ba2",
|
| 1169 |
-
"metadata": {},
|
| 1170 |
-
"source": [
|
| 1171 |
-
"## D. Did the rebuilt results agree?\n",
|
| 1172 |
-
"\n",
|
| 1173 |
-
"This table is calculated from the new predictions. It compares the main outcomes with the original local reference. Identical random seeds and source revisions do not guarantee bitwise identity across GPU kernels or linear algebra libraries; numerical differences are reported rather than hidden. A changed scientific conclusion requires examination, even if all code cells ran."
|
| 1174 |
-
]
|
| 1175 |
-
},
|
| 1176 |
-
{
|
| 1177 |
-
"cell_type": "code",
|
| 1178 |
-
"execution_count": null,
|
| 1179 |
-
"id": "15dcdfe8",
|
| 1180 |
-
"metadata": {},
|
| 1181 |
-
"outputs": [],
|
| 1182 |
-
"source": [
|
| 1183 |
-
"def value(frame, query, column='mean'):\n",
|
| 1184 |
-
" rows = frame.query(query)\n",
|
| 1185 |
-
" assert len(rows) == 1, (query, len(rows))\n",
|
| 1186 |
-
" return float(rows.iloc[0][column])\n",
|
| 1187 |
-
"new = [\n",
|
| 1188 |
-
" ('MAT layer 16 balanced accuracy', .9821428571428572,\n",
|
| 1189 |
-
" value(layers, \"layer == 16 and method == 'token_norm' and exclude_2frame == False\", 'balanced_accuracy')),\n",
|
| 1190 |
-
" ('IntPhys2 possible > impossible', 41/120,\n",
|
| 1191 |
-
" value(main_physical, \"method == 'graded_ensemble'\", 'matched_pair_accuracy')),\n",
|
| 1192 |
-
" ('UCF core level ranking', .9995, float(recomputed['layer16'])),\n",
|
| 1193 |
-
" ('UCF pixel-MAE level ranking', 1., float(recomputed['negative_pixel_mae'])),\n",
|
| 1194 |
-
" ('UCF fixed-threshold balanced accuracy', .68125, float(balanced_accuracy)),\n",
|
| 1195 |
-
" ('Direction: source holdout', .73,\n",
|
| 1196 |
-
" value(csv('temporal_diagnostics/aot_summary.csv'), \"scheme == 'source_folds' and method == 'layer16_pooled' and metric == 'pair_accuracy'\")),\n",
|
| 1197 |
-
" ('Direction: action holdout', .49,\n",
|
| 1198 |
-
" value(csv('temporal_diagnostics/aot_summary.csv'), \"scheme == 'action_holdout' and method == 'layer16_pooled' and metric == 'pair_accuracy'\"))]\n",
|
| 1199 |
-
"comparison = pd.DataFrame(new, columns=['Measure', 'Original reference', 'Regenerated'])\n",
|
| 1200 |
-
"comparison['Difference (percentage points)'] = 100*(comparison.Regenerated-comparison['Original reference'])\n",
|
| 1201 |
-
"display(comparison.round(6))\n",
|
| 1202 |
-
"comparison.to_csv(BASE/'colab_reference_comparison.csv', index=False)"
|
| 1203 |
-
]
|
| 1204 |
-
},
|
| 1205 |
-
{
|
| 1206 |
-
"cell_type": "markdown",
|
| 1207 |
-
"id": "1d273969",
|
| 1208 |
-
"metadata": {},
|
| 1209 |
-
"source": [
|
| 1210 |
-
"### Completion record and downloadable results\n",
|
| 1211 |
-
"\n",
|
| 1212 |
-
"This final cell requires all seven stages, checks the raw reconstruction and null controls, saves package versions, and creates a results archive. The archive contains features, fitted weights, predictions, figures, protocols and logs. The large raw video/model downloads remain separate and reproducibly downloadable. Save the executed notebook using Colab's **File → Download → Download .ipynb**; download the results ZIP from Colab's Files panel if wanted.\n",
|
| 1213 |
-
"\n",
|
| 1214 |
-
"Public sources: [runtime and lossless MAT inputs](https://huggingface.co/datasets/Iuda/vjepa-temporal-coherence), [V-JEPA 2 checkpoint](https://huggingface.co/facebook/vjepa2-vitl-fpc64-256), [UCF101 subset](https://huggingface.co/datasets/sayakpaul/ucf101-subset), and [IntPhys2](https://huggingface.co/datasets/facebook/IntPhys2). Source revisions are pinned above. The local-reference discussion draws on [Shuffle and Learn](https://arxiv.org/abs/1603.08561) and [Learning and Using the Arrow of Time](https://openaccess.thecvf.com/content_cvpr_2018/papers/Wei_Learning_and_Using_CVPR_2018_paper.pdf)."
|
| 1215 |
-
]
|
| 1216 |
-
},
|
| 1217 |
-
{
|
| 1218 |
-
"cell_type": "code",
|
| 1219 |
-
"execution_count": null,
|
| 1220 |
-
"id": "4ae5375a",
|
| 1221 |
-
"metadata": {},
|
| 1222 |
-
"outputs": [],
|
| 1223 |
-
"source": [
|
| 1224 |
-
"import importlib.metadata as package_metadata\n",
|
| 1225 |
-
"receipts = [json.loads((ROOT/f'logs/{s}_complete.json').read_text()) for s in pipeline.STAGES]\n",
|
| 1226 |
-
"raw_checks = saved_json('raw_input_verification.json')\n",
|
| 1227 |
-
"assert len(raw_checks) == 32 and all(r['raw_pixels_verified'] for r in raw_checks)\n",
|
| 1228 |
-
"assert np.allclose(null_pairs.forward, null_pairs.reverse, atol=1e-10, rtol=0)\n",
|
| 1229 |
-
"validation = {'complete': True, 'raw_cells_verified': len(raw_checks), 'stages': receipts,\n",
|
| 1230 |
-
" 'cold_start': json.loads((ROOT/'logs/cold_start.json').read_text()),\n",
|
| 1231 |
-
" 'elapsed_seconds': round(time.time()-STARTED, 2), 'python': sys.version,\n",
|
| 1232 |
-
" 'versions': {p: package_metadata.version(p) for p in ['torch','transformers','numpy','scipy','pandas','scikit-learn','pillow','opencv-python-headless']},\n",
|
| 1233 |
-
" 'bundle_revision': BUNDLE_REVISION, 'human_ratings_collected': False,\n",
|
| 1234 |
-
" 'reference_comparison': comparison.to_dict('records')}\n",
|
| 1235 |
-
"(BASE/'colab_validation.json').write_text(json.dumps(validation, indent=2))\n",
|
| 1236 |
-
"archive_path = ROOT/'colab_results.zip'\n",
|
| 1237 |
-
"with zipfile.ZipFile(archive_path, 'w', zipfile.ZIP_DEFLATED) as archive:\n",
|
| 1238 |
-
" for folder in [ROOT/'outputs', ROOT/'logs']:\n",
|
| 1239 |
-
" for path in folder.rglob('*'):\n",
|
| 1240 |
-
" if path.is_file(): archive.write(path, path.relative_to(ROOT))\n",
|
| 1241 |
-
"print('ALL STAGES COMPLETE. Results:', archive_path)\n",
|
| 1242 |
-
"display(pd.DataFrame(receipts)[['stage','elapsed_seconds','completed_utc']])"
|
| 1243 |
]
|
| 1244 |
}
|
| 1245 |
],
|
|
@@ -1259,12 +329,11 @@
|
|
| 1259 |
"name": "python"
|
| 1260 |
},
|
| 1261 |
"temporal_coherence": {
|
| 1262 |
-
"
|
|
|
|
| 1263 |
"encoder_frozen": true,
|
| 1264 |
-
"
|
| 1265 |
-
"layer": 16
|
| 1266 |
-
"raw_regeneration": true,
|
| 1267 |
-
"seed": 20260927
|
| 1268 |
}
|
| 1269 |
},
|
| 1270 |
"nbformat": 4,
|
|
|
|
| 2 |
"cells": [
|
| 3 |
{
|
| 4 |
"cell_type": "markdown",
|
| 5 |
+
"id": "54cdee01",
|
| 6 |
"metadata": {},
|
| 7 |
"source": [
|
| 8 |
+
"# What temporal information is decodable from layer 16?\n",
|
| 9 |
"\n",
|
| 10 |
+
"Freeze V-JEPA 2. **Train a separate linear classifier within each dataset.** Keep related videos together in held-out folds. No classifier transfers between datasets.\n",
|
| 11 |
"\n",
|
| 12 |
+
"**Colab: L4/A100 → Run all.** Raw inputs download anonymously. All computation is below."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
]
|
| 14 |
},
|
| 15 |
{
|
| 16 |
"cell_type": "code",
|
| 17 |
"execution_count": null,
|
| 18 |
+
"id": "0613e725",
|
| 19 |
"metadata": {},
|
| 20 |
"outputs": [],
|
| 21 |
"source": [
|
| 22 |
+
"import os, sys, subprocess, json, hashlib, zipfile, tarfile, shutil\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
"from pathlib import Path\n",
|
| 24 |
+
"os.environ['HF_HUB_DISABLE_IMPLICIT_TOKEN'] = '1'\n",
|
| 25 |
+
"subprocess.run([sys.executable, '-m', 'pip', 'install', '-q', 'transformers==5.15.1',\n",
|
| 26 |
+
" 'scikit-learn==1.6.1', 'opencv-python-headless==4.13.0.92'], check=True)\n",
|
| 27 |
"import numpy as np\n",
|
| 28 |
"import pandas as pd\n",
|
| 29 |
"import matplotlib.pyplot as plt\n",
|
| 30 |
+
"import cv2, torch\n",
|
| 31 |
+
"import torch.nn.functional as F\n",
|
| 32 |
+
"from PIL import Image\n",
|
| 33 |
+
"from huggingface_hub import hf_hub_download\n",
|
| 34 |
+
"from transformers import AutoModel\n",
|
| 35 |
+
"from sklearn.model_selection import GroupKFold\n",
|
| 36 |
+
"from sklearn.pipeline import make_pipeline\n",
|
| 37 |
+
"from sklearn.preprocessing import StandardScaler\n",
|
| 38 |
+
"from sklearn.linear_model import LogisticRegression\n",
|
| 39 |
+
"from sklearn.metrics import balanced_accuracy_score, roc_auc_score\n",
|
| 40 |
"\n",
|
| 41 |
+
"assert torch.cuda.is_available() and torch.cuda.is_bf16_supported(including_emulation=False), 'Select an L4/A100 GPU.'\n",
|
| 42 |
"SEED = 20260927\n",
|
| 43 |
+
"torch.manual_seed(SEED)\n",
|
| 44 |
+
"torch.set_num_threads(4)\n",
|
| 45 |
+
"cv2.setNumThreads(1)\n",
|
| 46 |
+
"OUT = Path('/content/layer16_within_dataset')\n",
|
| 47 |
+
"OUT.mkdir(exist_ok=True)\n",
|
| 48 |
+
"BUNDLE_REV = 'e2076dd5e294a38a1eae370a446cf3632f2616b4'\n",
|
| 49 |
+
"MODEL_REV = 'b3c1679b7c34d3255ef3547f27c7b226aefab26f'\n",
|
| 50 |
"\n",
|
| 51 |
+
"def download(repo, filename, revision):\n",
|
| 52 |
+
" return Path(hf_hub_download(repo, filename, repo_type='dataset', revision=revision, token=False))"
|
|
|
|
|
|
|
| 53 |
]
|
| 54 |
},
|
| 55 |
{
|
| 56 |
"cell_type": "markdown",
|
| 57 |
+
"id": "ab924751",
|
| 58 |
"metadata": {},
|
| 59 |
"source": [
|
| 60 |
+
"## 1. Shared feature extraction\n",
|
|
|
|
|
|
|
| 61 |
"\n",
|
| 62 |
+
"Layer 16: normalize tokens, then average to 1,024 features. The encoder is frozen; the predictor is unused."
|
| 63 |
]
|
| 64 |
},
|
| 65 |
{
|
| 66 |
"cell_type": "code",
|
| 67 |
"execution_count": null,
|
| 68 |
+
"id": "354241b5",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
"metadata": {},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
"outputs": [],
|
| 71 |
"source": [
|
| 72 |
+
"model = AutoModel.from_pretrained('facebook/vjepa2-vitl-fpc64-256', revision=MODEL_REV,\n",
|
| 73 |
+
" token=False, dtype=torch.bfloat16, attn_implementation='sdpa').eval().requires_grad_(False).cuda()\n",
|
| 74 |
+
"mean = torch.tensor([.485, .456, .406], device='cuda')[None, None, :, None, None]\n",
|
| 75 |
+
"std = torch.tensor([.229, .224, .225], device='cuda')[None, None, :, None, None]\n",
|
| 76 |
+
"rows, features, pixels = [], [], []\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
"\n",
|
| 78 |
+
"def crop(frame):\n",
|
| 79 |
+
" image = Image.fromarray(frame)\n",
|
| 80 |
+
" w, h = image.size\n",
|
| 81 |
+
" image = image.resize((int(w * 292/min(w,h)), int(h * 292/min(w,h))), Image.Resampling.BILINEAR)\n",
|
| 82 |
+
" w, h = image.size\n",
|
| 83 |
+
" return np.asarray(image.crop(((w-256)//2, (h-256)//2, (w-256)//2+256, (h-256)//2+256)))\n",
|
| 84 |
"\n",
|
| 85 |
+
"def read_video(path, indices=None, count=90):\n",
|
| 86 |
+
" cap = cv2.VideoCapture(str(path))\n",
|
| 87 |
+
" n = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))\n",
|
| 88 |
+
" indices = np.rint(np.linspace(0, n-1, count)).astype(int) if indices is None else np.asarray(indices)\n",
|
| 89 |
+
" assert len(set(indices)) == len(indices) and min(indices) >= 0 and max(indices) < n\n",
|
| 90 |
+
" wanted, frames = set(indices), []\n",
|
| 91 |
+
" try:\n",
|
| 92 |
+
" for i in range(max(indices)+1):\n",
|
| 93 |
+
" ok, frame = cap.read()\n",
|
| 94 |
+
" assert ok, f'Decode failed: {path}, frame {i}'\n",
|
| 95 |
+
" if i in wanted: frames.append(crop(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)))\n",
|
| 96 |
+
" finally:\n",
|
| 97 |
+
" cap.release()\n",
|
| 98 |
+
" return np.stack(frames)\n",
|
| 99 |
"\n",
|
| 100 |
+
"@torch.inference_mode()\n",
|
| 101 |
+
"def add(frames, **record):\n",
|
| 102 |
+
" pooled = []\n",
|
| 103 |
+
" def capture(module, inputs, output):\n",
|
| 104 |
+
" z = F.layer_norm(output[0].float(), (1024,), eps=model.config.layer_norm_eps)\n",
|
| 105 |
+
" pooled.append(z.mean(1)[0].cpu().numpy())\n",
|
| 106 |
+
" hook = model.encoder.layer[15].register_forward_hook(capture)\n",
|
| 107 |
+
" try:\n",
|
| 108 |
+
" x = torch.from_numpy(np.ascontiguousarray(frames)).permute(0,3,1,2)[None].cuda().float() / 255\n",
|
| 109 |
+
" model.encoder(pixel_values_videos=((x-mean)/std).to(torch.bfloat16))\n",
|
| 110 |
+
" finally:\n",
|
| 111 |
+
" hook.remove()\n",
|
| 112 |
+
" endpoints = [np.asarray(Image.fromarray(f).resize((8,8)), dtype=float) for f in frames[[0,-1]]]\n",
|
| 113 |
+
" mae = np.abs(np.diff(frames.astype(np.float32), axis=0)).mean() / 255\n",
|
| 114 |
+
" pixels.append(np.r_[mae, ((endpoints[1]-endpoints[0])/255).ravel()])\n",
|
| 115 |
+
" features.append(pooled[0])\n",
|
| 116 |
+
" rows.append(record)"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
]
|
| 118 |
},
|
| 119 |
{
|
| 120 |
"cell_type": "markdown",
|
| 121 |
+
"id": "62de8e7f",
|
| 122 |
"metadata": {},
|
| 123 |
"source": [
|
| 124 |
+
"## 2. MAT: intact versus shuffled\n",
|
|
|
|
|
|
|
| 125 |
"\n",
|
| 126 |
+
"Four related sources, 90 frames. Exclude the defective two-frame condition. Intact forward and reversed videos share the positive label."
|
| 127 |
]
|
| 128 |
},
|
| 129 |
{
|
| 130 |
"cell_type": "code",
|
| 131 |
"execution_count": null,
|
| 132 |
+
"id": "ae9acd07",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
"metadata": {},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
"outputs": [],
|
| 135 |
"source": [
|
| 136 |
+
"bundle = download('Iuda/vjepa-temporal-coherence', 'mat_raw_frames.zip', BUNDLE_REV)\n",
|
| 137 |
+
"assert hashlib.sha256(bundle.read_bytes()).hexdigest() == '67f6e6eff15fb0eac0d5e7b7545faa2c02fcec063db038d717f424736ec25941'\n",
|
| 138 |
+
"blocks = [1, 2, 3, 6, 9, 15, 18, 90]\n",
|
| 139 |
+
"with zipfile.ZipFile(bundle) as archive:\n",
|
| 140 |
+
" for source in json.loads(archive.read('manifest.json'))['sources']:\n",
|
| 141 |
+
" raw = np.load(archive.open(source['family'] + '_frames.npy'), allow_pickle=False)\n",
|
| 142 |
+
" small = np.stack([crop(frame) for frame in raw])\n",
|
| 143 |
+
" for clip in source['clips']:\n",
|
| 144 |
+
" i, ids = clip['cell']-1, clip['indices']\n",
|
| 145 |
+
" assert hashlib.sha256(raw[ids].tobytes()).hexdigest() == clip['pixel_sha256_THWC']\n",
|
| 146 |
+
" if i % 8 == 1: continue\n",
|
| 147 |
+
" reference = source['clips'][7 + 8*(i//8)]['indices']\n",
|
| 148 |
+
" assert len(set(ids)) == 90 and sorted(ids) == sorted(reference)\n",
|
| 149 |
+
" name = source['family'] + '_' + ('A' if i < 8 else 'B')\n",
|
| 150 |
+
" block = blocks[i % 8]\n",
|
| 151 |
+
" for forward in [1, 0]:\n",
|
| 152 |
+
" frames = small[ids][::1 if forward else -1]\n",
|
| 153 |
+
" add(frames, dataset='MAT', source=name, pair=name, block=block,\n",
|
| 154 |
+
" intact=int(block == 90), forward=forward)\n",
|
| 155 |
+
"print('MAT:', sum(r['dataset'] == 'MAT' for r in rows), 'inputs')"
|
| 156 |
]
|
| 157 |
},
|
| 158 |
{
|
| 159 |
"cell_type": "markdown",
|
| 160 |
+
"id": "a0a789fc",
|
| 161 |
"metadata": {},
|
| 162 |
"source": [
|
| 163 |
+
"## 3. UCF: order and arrow of time\n",
|
|
|
|
|
|
|
| 164 |
"\n",
|
| 165 |
+
"100 sources, 64 frames. Order uses intact/block-shuffled videos in both directions. A separate direction classifier uses only intact forward/reverse pairs."
|
| 166 |
]
|
| 167 |
},
|
| 168 |
{
|
| 169 |
"cell_type": "code",
|
| 170 |
"execution_count": null,
|
| 171 |
+
"id": "3fff97a2",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 172 |
"metadata": {},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 173 |
"outputs": [],
|
| 174 |
"source": [
|
| 175 |
+
"selection = json.loads(download('Iuda/vjepa-temporal-coherence', 'ucf_sources.json', BUNDLE_REV).read_text())\n",
|
| 176 |
+
"archive_path = download('sayakpaul/ucf101-subset', 'UCF101_subset.tar.gz', 'b9984b8d2a95e4a1879e1b071e9433858d0bc24a')\n",
|
| 177 |
+
"assert hashlib.sha256(archive_path.read_bytes()).hexdigest() == 'e9fcc76af48d320be88c5265f2e0576ecd615956976f6ce4742fdf2b042b71eb'\n",
|
| 178 |
+
"with tarfile.open(archive_path) as archive:\n",
|
| 179 |
+
" for i, source in enumerate(selection, 1):\n",
|
| 180 |
+
" path = OUT.parent/'source.avi'\n",
|
| 181 |
+
" path.write_bytes(archive.extractfile(source['archive_member']).read())\n",
|
| 182 |
+
" assert hashlib.sha256(path.read_bytes()).hexdigest() == source['source_sha256']\n",
|
| 183 |
+
" video = read_video(path, source['sampled_indices'])\n",
|
| 184 |
+
" rng = np.random.default_rng(int(hashlib.sha256((str(SEED)+source['source_id']).encode()).hexdigest()[:8], 16))\n",
|
| 185 |
+
" for block in [1, 4, 8, 16, 64]:\n",
|
| 186 |
+
" order = np.arange(64)\n",
|
| 187 |
+
" if block < 64:\n",
|
| 188 |
+
" while np.array_equal(order, np.arange(64)):\n",
|
| 189 |
+
" order = np.arange(64).reshape(-1,block)[rng.permutation(64//block)].ravel()\n",
|
| 190 |
+
" for forward in [1, 0]:\n",
|
| 191 |
+
" add(video[order][::1 if forward else -1], dataset='UCF', source=source['group_id'],\n",
|
| 192 |
+
" pair=source['group_id'], block=block, intact=int(block == 64), forward=forward)\n",
|
| 193 |
+
" if i % 10 == 0: print(f'UCF: {i}/100 sources')"
|
| 194 |
]
|
| 195 |
},
|
| 196 |
{
|
| 197 |
"cell_type": "markdown",
|
| 198 |
+
"id": "f13c1188",
|
| 199 |
"metadata": {},
|
| 200 |
"source": [
|
| 201 |
+
"## 4. IntPhys: possible versus impossible\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 202 |
"\n",
|
| 203 |
+
"240 continuity videos, 60 matched scenes. Fit a new probe using scene-held-out folds. This is an exploratory representation test, separate from the benchmark's standard protocol."
|
| 204 |
]
|
| 205 |
},
|
| 206 |
{
|
| 207 |
"cell_type": "code",
|
| 208 |
"execution_count": null,
|
| 209 |
+
"id": "b40053de",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 210 |
"metadata": {},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 211 |
"outputs": [],
|
| 212 |
"source": [
|
| 213 |
+
"INTPHYS_REV = 'a077a2f94e25889016fc6e5983cf21e2ddc25fb2'\n",
|
| 214 |
+
"metadata = pd.read_csv(download('facebook/IntPhys2', 'Main/metadata.csv', INTPHYS_REV), keep_default_na=False)\n",
|
| 215 |
+
"metadata = metadata[metadata.condition.eq('continuity')].sort_values(['SceneIndex','type'])\n",
|
| 216 |
+
"assert len(metadata) == 240 and metadata.SceneIndex.nunique() == 60\n",
|
| 217 |
+
"for i, row in enumerate(metadata.to_dict('records'), 1):\n",
|
| 218 |
+
" path = download('facebook/IntPhys2', 'Main/' + row['file_name'], INTPHYS_REV)\n",
|
| 219 |
+
" pair, label = row['type'].split('_')\n",
|
| 220 |
+
" add(read_video(path), dataset='IntPhys', source=str(row['SceneIndex']),\n",
|
| 221 |
+
" pair=f\"{row['SceneIndex']}_{pair}\", possible=int(label == 'Possible'))\n",
|
| 222 |
+
" if i % 40 == 0: print(f'IntPhys: {i}/240 videos')\n",
|
| 223 |
+
"df = pd.DataFrame(rows)\n",
|
| 224 |
+
"X, P = np.stack(features).astype(float), np.stack(pixels)\n",
|
| 225 |
+
"assert len(df) == len(X) == len(P) == 1296 and X.shape[1] == 1024 and np.isfinite(X).all()\n",
|
| 226 |
+
"df.to_csv(OUT/'inputs.csv', index=False)\n",
|
| 227 |
+
"np.savez_compressed(OUT/'features.npz', layer16=X, pixels=P, model_revision=MODEL_REV)"
|
| 228 |
]
|
| 229 |
},
|
| 230 |
{
|
| 231 |
"cell_type": "markdown",
|
| 232 |
+
"id": "d7269e99",
|
| 233 |
"metadata": {},
|
| 234 |
"source": [
|
| 235 |
+
"## 5. Train and evaluate within each dataset\n",
|
|
|
|
|
|
|
| 236 |
"\n",
|
| 237 |
+
"Fresh scaler + logistic regression in every fold; fixed C=1. All variants of a source stay together. Baseline: pixel change for order/continuity, endpoint pixels for direction."
|
| 238 |
]
|
| 239 |
},
|
| 240 |
{
|
| 241 |
"cell_type": "code",
|
| 242 |
"execution_count": null,
|
| 243 |
+
"id": "0ec0c4f0",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 244 |
"metadata": {},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 245 |
"outputs": [],
|
| 246 |
"source": [
|
| 247 |
+
"tasks = {'MAT order': ('MAT','intact'), 'UCF order': ('UCF','intact'),\n",
|
| 248 |
+
" 'UCF direction': ('UCF','forward'), 'IntPhys continuity': ('IntPhys','possible')}\n",
|
| 249 |
+
"results, predictions = [], []\n",
|
| 250 |
+
"for task, (dataset, target) in tasks.items():\n",
|
| 251 |
+
" data = df[df.dataset.eq(dataset)]\n",
|
| 252 |
+
" if target == 'forward': data = data[data.intact.eq(1)]\n",
|
| 253 |
+
" idx, y, groups = data.index.to_numpy(), data[target].to_numpy(int), data.source.to_numpy()\n",
|
| 254 |
+
" splits = list(GroupKFold(min(5, len(set(groups))), shuffle=True, random_state=SEED).split(idx, y, groups))\n",
|
| 255 |
+
" baseline = P[idx, 1:] if target == 'forward' else P[idx, :1]\n",
|
| 256 |
+
" for method, values in [('Layer 16', X[idx]), ('Pixels', baseline)]:\n",
|
| 257 |
+
" scores = np.empty(len(y))\n",
|
| 258 |
+
" for train, test in splits:\n",
|
| 259 |
+
" assert set(groups[train]).isdisjoint(groups[test])\n",
|
| 260 |
+
" probe = make_pipeline(StandardScaler(), LogisticRegression(C=1, class_weight='balanced', max_iter=5000))\n",
|
| 261 |
+
" probe.fit(values[train], y[train])\n",
|
| 262 |
+
" scores[test] = probe.decision_function(values[test])\n",
|
| 263 |
+
" output = data.copy()\n",
|
| 264 |
+
" output['task'], output['method'], output['label'], output['score'] = task, method, y, scores\n",
|
| 265 |
+
" predictions.append(output)\n",
|
| 266 |
+
" pairs = []\n",
|
| 267 |
+
" for _, pair in output.groupby('pair'):\n",
|
| 268 |
+
" margin = pair.loc[pair.label.eq(1),'score'].to_numpy()[:,None] - pair.loc[pair.label.eq(0),'score'].to_numpy()\n",
|
| 269 |
+
" pairs.append(np.mean((margin > 0) + .5*(margin == 0)))\n",
|
| 270 |
+
" results.append(dict(task=task, method=method, sources=len(set(groups)),\n",
|
| 271 |
+
" balanced_accuracy=balanced_accuracy_score(y, scores >= 0),\n",
|
| 272 |
+
" auc=roc_auc_score(y, scores), within_source_ranking=np.mean(pairs)))\n",
|
| 273 |
+
"results = pd.DataFrame(results)\n",
|
| 274 |
+
"predictions = pd.concat(predictions, ignore_index=True)\n",
|
| 275 |
+
"display(results.round(3))"
|
| 276 |
]
|
| 277 |
},
|
| 278 |
{
|
| 279 |
"cell_type": "markdown",
|
| 280 |
+
"id": "a602a1fb",
|
| 281 |
"metadata": {},
|
| 282 |
"source": [
|
| 283 |
+
"## 6. Results\n",
|
| 284 |
"\n",
|
| 285 |
+
"Balanced accuracy tests individual labels; within-source ranking compares matched conditions. Chance is 50%. These are held-out probe scores, not human coherence ratings."
|
| 286 |
]
|
| 287 |
},
|
| 288 |
{
|
| 289 |
"cell_type": "code",
|
| 290 |
"execution_count": null,
|
| 291 |
+
"id": "1803372e",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 292 |
"metadata": {},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 293 |
"outputs": [],
|
| 294 |
"source": [
|
| 295 |
+
"ax = results.pivot(index='task', columns='method', values='balanced_accuracy').plot.bar(figsize=(9,3.5), rot=15)\n",
|
| 296 |
+
"ax.axhline(.5, color='gray', linestyle='--')\n",
|
| 297 |
+
"ax.set(ylabel='Held-out balanced accuracy', xlabel='', ylim=(0,1))\n",
|
| 298 |
+
"ax.figure.tight_layout()\n",
|
| 299 |
+
"ax.figure.savefig(OUT/'probe_results.png', dpi=160)\n",
|
| 300 |
+
"plt.show()\n",
|
| 301 |
+
"results.to_csv(OUT/'results.csv', index=False)\n",
|
| 302 |
+
"predictions.to_csv(OUT/'predictions.csv', index=False)\n",
|
| 303 |
+
"shutil.make_archive(str(OUT)+'_results', 'zip', OUT)\n",
|
| 304 |
+
"print('Saved results:', str(OUT)+'_results.zip')"
|
| 305 |
]
|
| 306 |
},
|
| 307 |
{
|
| 308 |
"cell_type": "markdown",
|
| 309 |
+
"id": "d3478645",
|
| 310 |
"metadata": {},
|
| 311 |
"source": [
|
| 312 |
+
"**Readout:** Performance above chance supports accessible information for that dataset's labels. Pixel baselines constrain the interpretation. MAT has only four related sources; physical plausibility, playback direction and perceived coherence remain distinct."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 313 |
]
|
| 314 |
}
|
| 315 |
],
|
|
|
|
| 329 |
"name": "python"
|
| 330 |
},
|
| 331 |
"temporal_coherence": {
|
| 332 |
+
"classifier_training": true,
|
| 333 |
+
"cross_dataset_transfer": false,
|
| 334 |
"encoder_frozen": true,
|
| 335 |
+
"evaluation": "grouped within-dataset folds",
|
| 336 |
+
"layer": 16
|
|
|
|
|
|
|
| 337 |
}
|
| 338 |
},
|
| 339 |
"nbformat": 4,
|
temporal_coherence_colab_executed.ipynb
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
verification.json
CHANGED
|
@@ -1,80 +1,92 @@
|
|
| 1 |
{
|
| 2 |
-
"
|
| 3 |
"gpu": "NVIDIA L4",
|
| 4 |
"execution_passed": true,
|
| 5 |
-
"
|
| 6 |
-
|
| 7 |
-
"started_utc": "2026-09-27T14:15:41Z",
|
| 8 |
-
"preexisting_feature_files": 0,
|
| 9 |
-
"preexisting_prediction_files": 0,
|
| 10 |
-
"cold_start": true,
|
| 11 |
-
"anonymous_downloads": true,
|
| 12 |
-
"bundle_revision": "85b6a55f474a04a36a3149c45a6d9a3598f7c981",
|
| 13 |
-
"gpu": "NVIDIA L4"
|
| 14 |
-
},
|
| 15 |
-
"raw_stages_completed": [
|
| 16 |
-
"mat",
|
| 17 |
-
"pilot",
|
| 18 |
-
"layers",
|
| 19 |
-
"graded",
|
| 20 |
-
"physical",
|
| 21 |
-
"broad",
|
| 22 |
-
"direction"
|
| 23 |
-
],
|
| 24 |
-
"raw_stage_elapsed_seconds": 2225.4,
|
| 25 |
-
"validation_sequence": [
|
| 26 |
-
"All seven experimental stages regenerated from raw inputs with zero preexisting features or predictions.",
|
| 27 |
-
"The report then encountered a missing design_integrity.json dependency; the report was changed to derive it from the regenerated manifest.",
|
| 28 |
-
"A clean kernel executed all 34 corrected notebook code cells successfully, reusing the features generated in the raw run."
|
| 29 |
-
],
|
| 30 |
-
"full_notebook_execution": {
|
| 31 |
-
"output": "/content/temporal_coherence_colab_executed.ipynb",
|
| 32 |
-
"elapsed_seconds": 560.9585506916046,
|
| 33 |
"errors": [],
|
| 34 |
-
"executed_code_cells":
|
| 35 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
},
|
| 37 |
-
"
|
| 38 |
-
"executed_artifacts_retrieved": false,
|
| 39 |
-
"artifact_note": "The runtime expired before the final executed notebook and results ZIP were downloaded. Saved logs and retrieved metric CSVs are retained. The delivered notebook has cleared outputs.",
|
| 40 |
-
"arrow_of_time_pooled_pair_accuracy": [
|
| 41 |
{
|
| 42 |
-
"
|
| 43 |
-
"method": "
|
| 44 |
-
"
|
| 45 |
-
"
|
| 46 |
-
"
|
| 47 |
-
"
|
| 48 |
-
"ci95_low": "0.42",
|
| 49 |
-
"ci95_high": "0.6"
|
| 50 |
},
|
| 51 |
{
|
| 52 |
-
"
|
| 53 |
-
"method": "
|
| 54 |
-
"
|
| 55 |
-
"
|
| 56 |
-
"
|
| 57 |
-
"
|
| 58 |
-
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
}
|
| 61 |
],
|
| 62 |
-
"
|
| 63 |
-
"representative_clip": "drag_08",
|
| 64 |
-
"same_model_sha256": true,
|
| 65 |
-
"MAT_preprocessed_hashes_match_original": 32,
|
| 66 |
-
"layer16_pooled_max_abs_difference": 0.0008276179432868958,
|
| 67 |
-
"layer16_temporal_max_abs_difference": 0.017317771911621094,
|
| 68 |
-
"note": "Cross-platform activations are not bitwise identical. Regenerated metrics are compared separately; same-runtime feature reproduction uses the original tolerances."
|
| 69 |
-
},
|
| 70 |
-
"evidence_sha256": {
|
| 71 |
-
"colab_aot_summary.csv": "650236420e070b59ff7520805877c7c257841d22f4ac05ac20478aae24c337a6",
|
| 72 |
-
"colab_broad_summary.csv": "833da463aa24c11b05fbedff77b5d41fe67546c3f74d561f831227f2efdb28a9",
|
| 73 |
-
"colab_graded_summary.csv": "c82fc6319e0cf875a9e5f7608d5a013dc2d9b550825df8e472dc198e0f7a459d",
|
| 74 |
-
"colab_layer_summary.csv": "725cfe5d6fcf4502fe47622ef2c840a39634c97ad9ea00e94ad0e36cf1efb486",
|
| 75 |
-
"colab_physical_summary.csv": "a7e372918a249e0e4152b1b6e0c8cc827711b6292067904c569eb893e31dbb29",
|
| 76 |
-
"rebuild_run_2.log": "85c43686650bdd882123f0975f1d1afe74d456c0cf8c63dc93d1c9f01e9573f4",
|
| 77 |
-
"rebuild_run_3.log": "5f3d3aff4d5ed57f195e7b020b6b54997e4cc253f43b1e88a8184a2293bcfab0"
|
| 78 |
-
},
|
| 79 |
-
"colab_url": "https://colab.research.google.com/gist/UYildiz12/fa02787a1a0d611b613219cdd53fa859/temporal_coherence_colab.ipynb"
|
| 80 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"verified_utc": "2026-09-29T15:29:43.438497+00:00",
|
| 3 |
"gpu": "NVIDIA L4",
|
| 4 |
"execution_passed": true,
|
| 5 |
+
"execution": {
|
| 6 |
+
"elapsed_seconds": 942.6834290027618,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
"errors": [],
|
| 8 |
+
"executed_code_cells": 7,
|
| 9 |
+
"source_sha256": "5ad5ef99c2b96a6eba2c238cc42e6454bc62c36b7974dd44b0f946280d860f0c",
|
| 10 |
+
"executed_sha256": "518e3825593287bc1f1edf197716197e4d3712f877de194be95d51a80b3f52f6"
|
| 11 |
+
},
|
| 12 |
+
"analysis": "Independent classifiers fitted and evaluated within each dataset",
|
| 13 |
+
"cross_dataset_classifier_transfer": false,
|
| 14 |
+
"encoder_frozen": true,
|
| 15 |
+
"input_counts": {
|
| 16 |
+
"IntPhys": 240,
|
| 17 |
+
"MAT": 56,
|
| 18 |
+
"UCF": 1000
|
| 19 |
+
},
|
| 20 |
+
"source_counts": {
|
| 21 |
+
"IntPhys": 60,
|
| 22 |
+
"MAT": 4,
|
| 23 |
+
"UCF": 100
|
| 24 |
},
|
| 25 |
+
"results": [
|
|
|
|
|
|
|
|
|
|
| 26 |
{
|
| 27 |
+
"task": "MAT order",
|
| 28 |
+
"method": "Layer 16",
|
| 29 |
+
"sources": 4,
|
| 30 |
+
"balanced_accuracy": 1.0,
|
| 31 |
+
"auc": 1.0,
|
| 32 |
+
"within_source_ranking": 1.0
|
|
|
|
|
|
|
| 33 |
},
|
| 34 |
{
|
| 35 |
+
"task": "MAT order",
|
| 36 |
+
"method": "Pixels",
|
| 37 |
+
"sources": 4,
|
| 38 |
+
"balanced_accuracy": 0.8333333333333333,
|
| 39 |
+
"auc": 0.875,
|
| 40 |
+
"within_source_ranking": 1.0
|
| 41 |
+
},
|
| 42 |
+
{
|
| 43 |
+
"task": "UCF order",
|
| 44 |
+
"method": "Layer 16",
|
| 45 |
+
"sources": 100,
|
| 46 |
+
"balanced_accuracy": 0.945625,
|
| 47 |
+
"auc": 0.9907625,
|
| 48 |
+
"within_source_ranking": 0.999375
|
| 49 |
+
},
|
| 50 |
+
{
|
| 51 |
+
"task": "UCF order",
|
| 52 |
+
"method": "Pixels",
|
| 53 |
+
"sources": 100,
|
| 54 |
+
"balanced_accuracy": 0.635,
|
| 55 |
+
"auc": 0.6855,
|
| 56 |
+
"within_source_ranking": 1.0
|
| 57 |
+
},
|
| 58 |
+
{
|
| 59 |
+
"task": "UCF direction",
|
| 60 |
+
"method": "Layer 16",
|
| 61 |
+
"sources": 100,
|
| 62 |
+
"balanced_accuracy": 0.5549999999999999,
|
| 63 |
+
"auc": 0.5705,
|
| 64 |
+
"within_source_ranking": 0.7
|
| 65 |
+
},
|
| 66 |
+
{
|
| 67 |
+
"task": "UCF direction",
|
| 68 |
+
"method": "Pixels",
|
| 69 |
+
"sources": 100,
|
| 70 |
+
"balanced_accuracy": 0.53,
|
| 71 |
+
"auc": 0.5762999999999999,
|
| 72 |
+
"within_source_ranking": 0.53
|
| 73 |
+
},
|
| 74 |
+
{
|
| 75 |
+
"task": "IntPhys continuity",
|
| 76 |
+
"method": "Layer 16",
|
| 77 |
+
"sources": 60,
|
| 78 |
+
"balanced_accuracy": 0.5874999999999999,
|
| 79 |
+
"auc": 0.6088194444444445,
|
| 80 |
+
"within_source_ranking": 0.7916666666666666
|
| 81 |
+
},
|
| 82 |
+
{
|
| 83 |
+
"task": "IntPhys continuity",
|
| 84 |
+
"method": "Pixels",
|
| 85 |
+
"sources": 60,
|
| 86 |
+
"balanced_accuracy": 0.5,
|
| 87 |
+
"auc": 0.5002777777777778,
|
| 88 |
+
"within_source_ranking": 0.5166666666666667
|
| 89 |
}
|
| 90 |
],
|
| 91 |
+
"results_zip_sha256": "f34b2a653022eb1204d4c06e3554a7764958fb9b845bf90e52d018fd33f3aa06"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
}
|
within_dataset_results.csv
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
task,method,sources,balanced_accuracy,auc,within_source_ranking
|
| 2 |
+
MAT order,Layer 16,4,1.0,1.0,1.0
|
| 3 |
+
MAT order,Pixels,4,0.8333333333333333,0.875,1.0
|
| 4 |
+
UCF order,Layer 16,100,0.945625,0.9907625,0.999375
|
| 5 |
+
UCF order,Pixels,100,0.635,0.6855,1.0
|
| 6 |
+
UCF direction,Layer 16,100,0.5549999999999999,0.5705,0.7
|
| 7 |
+
UCF direction,Pixels,100,0.53,0.5762999999999999,0.53
|
| 8 |
+
IntPhys continuity,Layer 16,60,0.5874999999999999,0.6088194444444445,0.7916666666666666
|
| 9 |
+
IntPhys continuity,Pixels,60,0.5,0.5002777777777778,0.5166666666666667
|