fix: test_architecture.py — use os.path.dirname(__file__) instead of hardcoded /app for sys.path
Browse files- test_architecture.py +5 -4
test_architecture.py
CHANGED
|
@@ -11,10 +11,14 @@ Tests the complete forward pass with synthetic data to verify:
|
|
| 11 |
7. Loss function variants (smooth_l1, mse, cosine)
|
| 12 |
8. Anti-collapse regularizations (SIGReg, VICReg)
|
| 13 |
9. Parameter counting is correct
|
|
|
|
|
|
|
| 14 |
"""
|
| 15 |
|
|
|
|
| 16 |
import sys
|
| 17 |
-
|
|
|
|
| 18 |
|
| 19 |
import torch
|
| 20 |
import torch.nn as nn
|
|
@@ -256,9 +260,6 @@ def test_ablation_no_jepa():
|
|
| 256 |
"""no_jepa: model forward should skip JEPA entirely."""
|
| 257 |
print("\n=== Ablation: --no_jepa ===")
|
| 258 |
D, K, B, N_s = 256, 3, 2, 8
|
| 259 |
-
# The train_mrjepa.py handles this at model level: when use_jepa=False,
|
| 260 |
-
# the model skips target_encoder forward and returns task_loss only.
|
| 261 |
-
# Here we verify the JEPALoss still computes (it's the model that decides whether to call it).
|
| 262 |
cfg = JEPAObjectiveConfig(use_sigreg=True, sigreg_weight=0.1)
|
| 263 |
loss_fn = JEPALoss(cfg, D)
|
| 264 |
pred = torch.randn(B, K + 1, N_s, D, requires_grad=True)
|
|
|
|
| 11 |
7. Loss function variants (smooth_l1, mse, cosine)
|
| 12 |
8. Anti-collapse regularizations (SIGReg, VICReg)
|
| 13 |
9. Parameter counting is correct
|
| 14 |
+
|
| 15 |
+
Run from repo root: python test_architecture.py
|
| 16 |
"""
|
| 17 |
|
| 18 |
+
import os
|
| 19 |
import sys
|
| 20 |
+
# Ensure the repo root is on the path (where mr_jepa/ package lives)
|
| 21 |
+
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
| 22 |
|
| 23 |
import torch
|
| 24 |
import torch.nn as nn
|
|
|
|
| 260 |
"""no_jepa: model forward should skip JEPA entirely."""
|
| 261 |
print("\n=== Ablation: --no_jepa ===")
|
| 262 |
D, K, B, N_s = 256, 3, 2, 8
|
|
|
|
|
|
|
|
|
|
| 263 |
cfg = JEPAObjectiveConfig(use_sigreg=True, sigreg_weight=0.1)
|
| 264 |
loss_fn = JEPALoss(cfg, D)
|
| 265 |
pred = torch.randn(B, K + 1, N_s, D, requires_grad=True)
|