Upload src/pino/train.py with huggingface_hub
Browse files- src/pino/train.py +8 -2
src/pino/train.py
CHANGED
|
@@ -54,10 +54,12 @@ def pad_trajectory_collate(batch: list[dict[str, Any]]) -> dict[str, Any]:
|
|
| 54 |
bsz = len(batch)
|
| 55 |
|
| 56 |
emb_dim = batch[0]["tokens"].size(1)
|
|
|
|
|
|
|
| 57 |
# objective target width from the batch itself (138 for pyramid, 575 for all-tags)
|
| 58 |
obj_dim = batch[0]["target_obj"].size(-1)
|
| 59 |
tokens = torch.zeros(bsz, max_molecules, emb_dim, dtype=torch.float32)
|
| 60 |
-
physics = torch.zeros(bsz, max_timesteps, max_molecules,
|
| 61 |
src_key_padding_mask = torch.ones(bsz, max_molecules, dtype=torch.bool)
|
| 62 |
target_obj = torch.zeros(bsz, 3, obj_dim, dtype=torch.float32)
|
| 63 |
target_sub_seasonality = torch.zeros(bsz, 4, dtype=torch.float32)
|
|
@@ -273,6 +275,7 @@ def main():
|
|
| 273 |
parser.add_argument("--train-ratio", type=float, default=DEFAULT_TRAIN_RATIO, help="Molecule-disjoint train molecule ratio; default keeps a 15% molecule holdout")
|
| 274 |
parser.add_argument("--structural-source", choices=["morgan", "openpom_256", "pom_alltags"], default="morgan", help="Structural embedding block + objective target: 'morgan' (138-dim Morgan, input 151, 138-dim pyramid) | 'openpom_256' (genuine 256-dim OpenPOM, input 269, 138-dim pyramid) | 'pom_alltags' (genuine 256-dim OpenPOM, input 269, 575-dim molequles all-tags objective)")
|
| 275 |
parser.add_argument("--smoke-test", action="store_true", help="Run lightweight CPU smoke test")
|
|
|
|
| 276 |
args = parser.parse_args()
|
| 277 |
|
| 278 |
logging.basicConfig(
|
|
@@ -380,6 +383,7 @@ def main():
|
|
| 380 |
structural_source=engine_source,
|
| 381 |
genre_map=genre_map,
|
| 382 |
objective_dim=objective_dim,
|
|
|
|
| 383 |
)
|
| 384 |
val_dataset = FragranceTrajectoryDataset(
|
| 385 |
records=val_records,
|
|
@@ -387,6 +391,7 @@ def main():
|
|
| 387 |
structural_source=engine_source,
|
| 388 |
genre_map=genre_map,
|
| 389 |
objective_dim=objective_dim,
|
|
|
|
| 390 |
)
|
| 391 |
|
| 392 |
train_loader = DataLoader(
|
|
@@ -396,9 +401,10 @@ def main():
|
|
| 396 |
val_dataset, batch_size=cfg["batch_size"], shuffle=False, num_workers=args.workers, collate_fn=pad_trajectory_collate
|
| 397 |
)
|
| 398 |
|
|
|
|
| 399 |
model = PhysicsInformedMixtureTransformer(
|
| 400 |
embedding_dim=embedding_dim,
|
| 401 |
-
state_dim=
|
| 402 |
hidden_dim=cfg["hidden_dim"],
|
| 403 |
num_heads=cfg["num_heads"],
|
| 404 |
num_layers=cfg["num_layers"],
|
|
|
|
| 54 |
bsz = len(batch)
|
| 55 |
|
| 56 |
emb_dim = batch[0]["tokens"].size(1)
|
| 57 |
+
# physics channel count from the batch (2 = x_liq/logOAV, 3 = + gamma interaction)
|
| 58 |
+
phys_dim = batch[0]["physics"].size(-1)
|
| 59 |
# objective target width from the batch itself (138 for pyramid, 575 for all-tags)
|
| 60 |
obj_dim = batch[0]["target_obj"].size(-1)
|
| 61 |
tokens = torch.zeros(bsz, max_molecules, emb_dim, dtype=torch.float32)
|
| 62 |
+
physics = torch.zeros(bsz, max_timesteps, max_molecules, phys_dim, dtype=torch.float32)
|
| 63 |
src_key_padding_mask = torch.ones(bsz, max_molecules, dtype=torch.bool)
|
| 64 |
target_obj = torch.zeros(bsz, 3, obj_dim, dtype=torch.float32)
|
| 65 |
target_sub_seasonality = torch.zeros(bsz, 4, dtype=torch.float32)
|
|
|
|
| 275 |
parser.add_argument("--train-ratio", type=float, default=DEFAULT_TRAIN_RATIO, help="Molecule-disjoint train molecule ratio; default keeps a 15% molecule holdout")
|
| 276 |
parser.add_argument("--structural-source", choices=["morgan", "openpom_256", "pom_alltags"], default="morgan", help="Structural embedding block + objective target: 'morgan' (138-dim Morgan, input 151, 138-dim pyramid) | 'openpom_256' (genuine 256-dim OpenPOM, input 269, 138-dim pyramid) | 'pom_alltags' (genuine 256-dim OpenPOM, input 269, 575-dim molequles all-tags objective)")
|
| 277 |
parser.add_argument("--smoke-test", action="store_true", help="Run lightweight CPU smoke test")
|
| 278 |
+
parser.add_argument("--use-gamma", action="store_true", help="Add the UNIFAC blend-interaction (gamma) 3rd physics channel; requires a gamma-augmented dataset (physics_gamma field)")
|
| 279 |
args = parser.parse_args()
|
| 280 |
|
| 281 |
logging.basicConfig(
|
|
|
|
| 383 |
structural_source=engine_source,
|
| 384 |
genre_map=genre_map,
|
| 385 |
objective_dim=objective_dim,
|
| 386 |
+
use_gamma=args.use_gamma,
|
| 387 |
)
|
| 388 |
val_dataset = FragranceTrajectoryDataset(
|
| 389 |
records=val_records,
|
|
|
|
| 391 |
structural_source=engine_source,
|
| 392 |
genre_map=genre_map,
|
| 393 |
objective_dim=objective_dim,
|
| 394 |
+
use_gamma=args.use_gamma,
|
| 395 |
)
|
| 396 |
|
| 397 |
train_loader = DataLoader(
|
|
|
|
| 401 |
val_dataset, batch_size=cfg["batch_size"], shuffle=False, num_workers=args.workers, collate_fn=pad_trajectory_collate
|
| 402 |
)
|
| 403 |
|
| 404 |
+
state_dim = 3 if args.use_gamma else 2
|
| 405 |
model = PhysicsInformedMixtureTransformer(
|
| 406 |
embedding_dim=embedding_dim,
|
| 407 |
+
state_dim=state_dim,
|
| 408 |
hidden_dim=cfg["hidden_dim"],
|
| 409 |
num_heads=cfg["num_heads"],
|
| 410 |
num_layers=cfg["num_layers"],
|