|
|
|
@ -76,11 +76,9 @@ class TimeConditionedTrainConfig:
|
|
|
|
huber_beta: float = 0.05
|
|
|
|
huber_beta: float = 0.05
|
|
|
|
use_schedule: bool = True
|
|
|
|
use_schedule: bool = True
|
|
|
|
sample_weight_mode: str = "none"
|
|
|
|
sample_weight_mode: str = "none"
|
|
|
|
pso_outside_weight: float = 0.5
|
|
|
|
|
|
|
|
pso_inside_weight: float = 1.0
|
|
|
|
|
|
|
|
risk_weight: float = 2.5
|
|
|
|
risk_weight: float = 2.5
|
|
|
|
skin_lt_minus8_weight: float = 3.5
|
|
|
|
skin_lt_minus8_weight: float = 3.5
|
|
|
|
sample_weight_min: float = 0.25
|
|
|
|
sample_weight_min: float = 1.0
|
|
|
|
sample_weight_max: float = 4.0
|
|
|
|
sample_weight_max: float = 4.0
|
|
|
|
device: str = "cuda" if torch.cuda.is_available() else "cpu"
|
|
|
|
device: str = "cuda" if torch.cuda.is_available() else "cpu"
|
|
|
|
|
|
|
|
|
|
|
|
@ -143,29 +141,15 @@ def _build_sample_weight(data: dict, cfg: TimeConditionedTrainConfig, split: str
|
|
|
|
n = int(data[f"X_params_{split}"].shape[0])
|
|
|
|
n = int(data[f"X_params_{split}"].shape[0])
|
|
|
|
if mode in {"none", "off", "false"}:
|
|
|
|
if mode in {"none", "off", "false"}:
|
|
|
|
return np.ones((n,), dtype=np.float32)
|
|
|
|
return np.ones((n,), dtype=np.float32)
|
|
|
|
if mode not in {"pso_domain", "pso_domain_risk"}:
|
|
|
|
if mode != "risk_region":
|
|
|
|
raise ValueError(f"Unknown sample_weight_mode={cfg.sample_weight_mode!r}")
|
|
|
|
raise ValueError(f"Unknown sample_weight_mode={cfg.sample_weight_mode!r}")
|
|
|
|
|
|
|
|
|
|
|
|
params = _raw_params_from_processed_split(data, split)
|
|
|
|
params = _raw_params_from_processed_split(data, split)
|
|
|
|
pso_mask = (
|
|
|
|
weight = np.ones((n,), dtype=np.float32)
|
|
|
|
(params["k"] >= 0.001)
|
|
|
|
risk = (params["skin"] < -5.0) & (params["wellboreC"] > 0.1)
|
|
|
|
& (params["k"] <= 10.0)
|
|
|
|
skin_extreme = params["skin"] < -8.0
|
|
|
|
& (params["skin"] >= -10.0)
|
|
|
|
weight[risk] = np.maximum(weight[risk], float(cfg.risk_weight))
|
|
|
|
& (params["skin"] <= 10.0)
|
|
|
|
weight[skin_extreme] = np.maximum(weight[skin_extreme], float(cfg.skin_lt_minus8_weight))
|
|
|
|
& (params["wellboreC"] >= 1.0e-4)
|
|
|
|
|
|
|
|
& (params["wellboreC"] <= 2.0)
|
|
|
|
|
|
|
|
& (params["phi"] >= 0.01)
|
|
|
|
|
|
|
|
& (params["phi"] <= 0.5)
|
|
|
|
|
|
|
|
& (params["h"] >= 2.0)
|
|
|
|
|
|
|
|
& (params["h"] <= 50.0)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
weight = np.where(pso_mask, float(cfg.pso_inside_weight), float(cfg.pso_outside_weight)).astype(np.float32)
|
|
|
|
|
|
|
|
if mode == "pso_domain_risk":
|
|
|
|
|
|
|
|
risk = pso_mask & (params["skin"] < -5.0) & (params["wellboreC"] > 0.1)
|
|
|
|
|
|
|
|
skin_extreme = pso_mask & (params["skin"] < -8.0)
|
|
|
|
|
|
|
|
weight[risk] = np.maximum(weight[risk], float(cfg.risk_weight))
|
|
|
|
|
|
|
|
weight[skin_extreme] = np.maximum(weight[skin_extreme], float(cfg.skin_lt_minus8_weight))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
weight = np.clip(weight, float(cfg.sample_weight_min), float(cfg.sample_weight_max))
|
|
|
|
weight = np.clip(weight, float(cfg.sample_weight_min), float(cfg.sample_weight_max))
|
|
|
|
return weight.astype(np.float32)
|
|
|
|
return weight.astype(np.float32)
|
|
|
|
|