Free SKILL.md scraped from GitHub. Clone the repo or copy the file directly into your Claude Code skills directory.
npx versuz@latest install hiyenwong-ai-collection-collection-skills-brain-dnn-transformation-alignmentgit clone https://github.com/hiyenwong/ai_collection.gitcp ai_collection/SKILL.MD ~/.claude/skills/hiyenwong-ai-collection-collection-skills-brain-dnn-transformation-alignment/SKILL.md---
name: brain-dnn-transformation-alignment
description: "Category-theoretic framework for brain-to-DNN transformation alignment using natural transformations and representational consistency. Activation: brain-dnn alignment, transformation alignment, naturality, category theory neural alignment, representational similarity, brain-to-DNN mapping."
---
# Brain-DNN Transformation Alignment (Naturality Violation Score)
> A category-theoretic framework that measures brain-to-DNN alignment via natural transformations between functorial mappings, introducing the Naturality Violation Score (NVS) as a quantitative metric beyond Representational Similarity Analysis (RSA).
## Metadata
- **Source**: arXiv:2605.06420
- **Authors**: Kamitani Lab (Kyoto University)
- **Published**: 2026-05-09
- **Category**: q-bio.NC (Neurons and Cognition)
## Core Methodology
### Key Innovation
Traditional brain-DNN alignment relies on Representational Similarity Analysis (RSA), which compares pairwise representational geometries at single layers. This framework elevates alignment to the **category-theoretic level**: instead of comparing static representations, it measures how consistently brain and DNN representations **transform** across stimuli through natural transformations.
### Technical Framework
**1. Categorical Formulation**
- **Category C**: Stimuli space with morphisms representing stimulus transformations
- **Category D_brain**: Brain representational space (fMRI/MEG activity patterns)
- **Category D_dnn**: DNN representational space (layer activations)
- **Functors F, G**: Mappings from stimuli to brain/DNN representations respectively
**2. Natural Transformation (η)**
- A family of morphisms η_X: F(X) → G(X) for each object X in C
- Commutativity: For any morphism f: X → Y, the diagram F(X) → G(X) → G(Y) must equal F(X) → F(Y) → G(Y)
- Perfect alignment = commutative diagram at all points
**3. Naturality Violation Score (NVS)**
```
NVS = ||G(f) ∘ η_X - η_Y ∘ F(f)||
```
- Measures the degree of diagram non-commutativity
- Lower NVS = better transformation-level alignment
- Complements RSA by capturing **dynamic consistency** not just static similarity
**4. Implementation Pipeline**
1. Define stimulus transformation space (e.g., image augmentations, semantic shifts)
2. Compute brain representations F(X) for each stimulus
3. Compute DNN representations G(X) for each stimulus at each layer
4. Learn optimal linear mapping η between brain and DNN spaces
5. For each transformation f, compute naturality violation
6. Aggregate NVS across transformations → per-layer alignment score
### Code Example
```python
import numpy as np
from scipy.linalg import norm
def compute_nvs(brain_reps, dnn_reps, transformations, eta):
"""
Compute Naturality Violation Score.
Args:
brain_reps: np.array (N, D_brain) - brain representations
dnn_reps: np.array (N, D_dnn) - DNN representations
transformations: list of (i, j) pairs representing f: X_i -> X_j
eta: np.array (D_brain, D_dnn) - learned mapping matrix
Returns:
nvs: float - aggregated naturality violation score
"""
violations = []
for i, j in transformations:
# F(f): brain transformation
F_f = brain_reps[j] - brain_reps[i]
# G(f): DNN transformation
G_f = dnn_reps[j] - dnn_reps[i]
# Path 1: G(f) ∘ η_X_i
path1 = G_f @ eta[i] if eta.ndim == 2 else G_f * eta[i]
# Path 2: η_X_j ∘ F(f)
path2 = eta[j] @ F_f if eta.ndim == 2 else eta[j] * F_f
violations.append(norm(path1 - path2))
return np.mean(violations)
```
## Applications
- **Brain-DNN alignment research**: Beyond RSA, capture transformation-level consistency
- **Layer selection**: Identify which DNN layers best match brain transformation patterns
- **Model evaluation**: Compare architectures by their naturality scores
- **Neuroscience theory testing**: Validate hypotheses about brain representation structure
- **Transfer learning**: Guide DNN architecture design to better match brain processing
## Comparison with RSA
| Aspect | RSA | NVS (This Framework) |
|--------|-----|---------------------|
| What it measures | Static representational geometry | Dynamic transformation consistency |
| Granularity | Pairwise similarity | Morphism-level commutativity |
| Theoretical basis | Multivariate pattern analysis | Category theory (natural transformations) |
| Sensitivity | Layer-by-layer snapshot | Cross-stimulus transformation invariance |
## Pitfalls
- **Requires paired stimuli**: Need brain and DNN responses to the same stimulus set
- **Transformation design**: Choice of stimulus transformations affects NVS interpretation
- **Computational cost**: O(N²) transformation pairs for N stimuli
- **Linear mapping assumption**: η is typically learned linearly; nonlinear mappings need kernel methods
- **Not a replacement for RSA**: Complementary metric, should be used alongside RSA
## Related Skills
- neuroscience-of-transformers
- brain-dit-fmri-foundation-model
- computational-neuroscience-in-llm-era
- meta-learning-in-context-brain-decoding