mattbitzesty commited on
Commit
3fd8388
·
verified ·
1 Parent(s): bf57e19

Upload src/pino/pimt_model.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. src/pino/pimt_model.py +13 -2
src/pino/pimt_model.py CHANGED
@@ -84,6 +84,7 @@ class FragranceTrajectoryDataset(Dataset):
84
  label_noise: bool = True,
85
  genre_map: dict[str, int] | None = None,
86
  objective_dim: int = 138,
 
87
  ) -> None:
88
  self.data_path = Path(data_path) if data_path else None
89
  self.records = records
@@ -91,6 +92,7 @@ class FragranceTrajectoryDataset(Dataset):
91
  self.embedding_dim = embedding_dim
92
  self.state_dim = state_dim
93
  self.objective_dim = objective_dim
 
94
  self.embedding_engine = OlfactoryEmbeddingEngine(use_fallback=use_embedding_fallback, structural_source=structural_source)
95
  self.embedding_dim = self.embedding_engine.embedding_dim
96
  self.label_noise = label_noise
@@ -140,10 +142,17 @@ class FragranceTrajectoryDataset(Dataset):
140
  tokens.append(torch.from_numpy(z))
141
 
142
  # Dynamic states: time x ingredient x state, sized to the actual K.
143
- # Use only log10(OAV) and x_liquid as the physics signal.
 
 
 
 
 
144
  t_steps = len(trajectory)
145
  n_mol = len(tokens)
146
- states = np.zeros((t_steps, n_mol, 2), dtype=np.float32)
 
 
147
  for t, step in enumerate(trajectory):
148
  for j, comp in enumerate(formula):
149
  if j >= n_mol:
@@ -153,6 +162,8 @@ class FragranceTrajectoryDataset(Dataset):
153
  oav = step["OAV"].get(name, 0.0)
154
  states[t, j, 0] = x_liq
155
  states[t, j, 1] = np.log10(max(oav, 1e-10))
 
 
156
 
157
  strategy = record.get("metadata", {}).get("generation_strategy", "wildcard")
158
 
 
84
  label_noise: bool = True,
85
  genre_map: dict[str, int] | None = None,
86
  objective_dim: int = 138,
87
+ use_gamma: bool = False,
88
  ) -> None:
89
  self.data_path = Path(data_path) if data_path else None
90
  self.records = records
 
92
  self.embedding_dim = embedding_dim
93
  self.state_dim = state_dim
94
  self.objective_dim = objective_dim
95
+ self.use_gamma = use_gamma
96
  self.embedding_engine = OlfactoryEmbeddingEngine(use_fallback=use_embedding_fallback, structural_source=structural_source)
97
  self.embedding_dim = self.embedding_engine.embedding_dim
98
  self.label_noise = label_noise
 
142
  tokens.append(torch.from_numpy(z))
143
 
144
  # Dynamic states: time x ingredient x state, sized to the actual K.
145
+ # Channels: [x_liquid, log10 OAV] plus an optional 3rd channel carrying
146
+ # the UNIFAC blend-interaction term (log10 proportional activity
147
+ # coefficient gamma), recovered by augment_gamma_channel.py. The gamma
148
+ # channel is the NON-redundant physics: it depends on the whole mixture
149
+ # and is not recoverable from single-molecule embeddings (unlike
150
+ # volatility, which is ~76% MW-recoverable).
151
  t_steps = len(trajectory)
152
  n_mol = len(tokens)
153
+ gamma_traj = record.get("physics_gamma") # (T, S) or None
154
+ state_dim = 3 if (self.use_gamma and gamma_traj is not None) else 2
155
+ states = np.zeros((t_steps, n_mol, state_dim), dtype=np.float32)
156
  for t, step in enumerate(trajectory):
157
  for j, comp in enumerate(formula):
158
  if j >= n_mol:
 
162
  oav = step["OAV"].get(name, 0.0)
163
  states[t, j, 0] = x_liq
164
  states[t, j, 1] = np.log10(max(oav, 1e-10))
165
+ if state_dim == 3 and t < len(gamma_traj) and j < len(gamma_traj[t]):
166
+ states[t, j, 2] = float(gamma_traj[t][j])
167
 
168
  strategy = record.get("metadata", {}).get("generation_strategy", "wildcard")
169