sync utility feature mode code 2026-07-03
Browse files
workspace/scripts/train_utility_energy.py
CHANGED
|
@@ -16,6 +16,7 @@ if str(PROJECT_ROOT) not in sys.path:
|
|
| 16 |
|
| 17 |
import torch # noqa: E402
|
| 18 |
|
|
|
|
| 19 |
from cil.metrics import macro_micro_summary, pairwise_causal_dominance_ece # noqa: E402
|
| 20 |
from cil.models import ( # noqa: E402
|
| 21 |
ChartEncoder,
|
|
@@ -42,6 +43,12 @@ def main(argv: list[str] | None = None) -> int:
|
|
| 42 |
parser.add_argument("--listwise-rank", type=float, default=1.0)
|
| 43 |
parser.add_argument("--margin", type=float, default=0.5)
|
| 44 |
parser.add_argument("--temperature", type=float, default=1.0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
args = parser.parse_args(argv)
|
| 46 |
|
| 47 |
random.seed(args.seed)
|
|
@@ -50,7 +57,11 @@ def main(argv: list[str] | None = None) -> int:
|
|
| 50 |
out_dir.mkdir(parents=True, exist_ok=True)
|
| 51 |
_write_provenance(out_dir, args)
|
| 52 |
|
| 53 |
-
charts, index = load_charts(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
if not charts:
|
| 55 |
raise SystemExit("utility energy training requires at least one outcome-visible chart")
|
| 56 |
normalizer = TangentNormalizer.fit(torch.cat([chart.tangents for chart in charts], dim=0))
|
|
@@ -112,6 +123,7 @@ def main(argv: list[str] | None = None) -> int:
|
|
| 112 |
"margin": args.margin,
|
| 113 |
"temperature": args.temperature,
|
| 114 |
},
|
|
|
|
| 115 |
"rows": rows,
|
| 116 |
"summary": summary,
|
| 117 |
}
|
|
@@ -125,6 +137,7 @@ def main(argv: list[str] | None = None) -> int:
|
|
| 125 |
"tangent_dim": tangent_dim,
|
| 126 |
"data_hash": index.get("content_hash"),
|
| 127 |
"split_hash": index.get("split_hash"),
|
|
|
|
| 128 |
},
|
| 129 |
out_dir / "model.pt",
|
| 130 |
)
|
|
|
|
| 16 |
|
| 17 |
import torch # noqa: E402
|
| 18 |
|
| 19 |
+
from cil.chart_features import CHART_FEATURE_MODES # noqa: E402
|
| 20 |
from cil.metrics import macro_micro_summary, pairwise_causal_dominance_ece # noqa: E402
|
| 21 |
from cil.models import ( # noqa: E402
|
| 22 |
ChartEncoder,
|
|
|
|
| 43 |
parser.add_argument("--listwise-rank", type=float, default=1.0)
|
| 44 |
parser.add_argument("--margin", type=float, default=0.5)
|
| 45 |
parser.add_argument("--temperature", type=float, default=1.0)
|
| 46 |
+
parser.add_argument(
|
| 47 |
+
"--chart-feature-mode",
|
| 48 |
+
choices=CHART_FEATURE_MODES,
|
| 49 |
+
default="base",
|
| 50 |
+
help="Deployment-visible chart feature family used by ChartEncoder.",
|
| 51 |
+
)
|
| 52 |
args = parser.parse_args(argv)
|
| 53 |
|
| 54 |
random.seed(args.seed)
|
|
|
|
| 57 |
out_dir.mkdir(parents=True, exist_ok=True)
|
| 58 |
_write_provenance(out_dir, args)
|
| 59 |
|
| 60 |
+
charts, index = load_charts(
|
| 61 |
+
args.dataset,
|
| 62 |
+
max_charts=args.max_charts,
|
| 63 |
+
chart_feature_mode=args.chart_feature_mode,
|
| 64 |
+
)
|
| 65 |
if not charts:
|
| 66 |
raise SystemExit("utility energy training requires at least one outcome-visible chart")
|
| 67 |
normalizer = TangentNormalizer.fit(torch.cat([chart.tangents for chart in charts], dim=0))
|
|
|
|
| 123 |
"margin": args.margin,
|
| 124 |
"temperature": args.temperature,
|
| 125 |
},
|
| 126 |
+
"chart_feature_mode": args.chart_feature_mode,
|
| 127 |
"rows": rows,
|
| 128 |
"summary": summary,
|
| 129 |
}
|
|
|
|
| 137 |
"tangent_dim": tangent_dim,
|
| 138 |
"data_hash": index.get("content_hash"),
|
| 139 |
"split_hash": index.get("split_hash"),
|
| 140 |
+
"chart_feature_mode": args.chart_feature_mode,
|
| 141 |
},
|
| 142 |
out_dir / "model.pt",
|
| 143 |
)
|