Commit 75845206 authored by Zhang, Chen's avatar Zhang, Chen
Browse files

adjust for mo film

parent 56db3334
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ if __name__ == "__main__":
        "n_head": 32,
        "num_encoder_layers": 6,
        "input_dim": 150,
        "output_dim": 17,
        "output_dim": 14,
        "to_log": True,
    }

@@ -23,7 +23,7 @@ if __name__ == "__main__":
        "optimizer": "Adam",
        "loss": "composite",
        "cache_dir": "data",
        "experiment_name": "nTrace_xx_film_6layer",
        "experiment_name": "nTrace_mo_film_5layer",
        "run_name": "d2048_h32_l6",
        "datadir": "expdata",
    }
+3 −3
Original line number Diff line number Diff line
@@ -132,9 +132,9 @@ def visualize_single_epoch(
        "bulk2_sld",
        "bulk2_thickness",
        "bulk2_roughness",
        "bulk3_sld",
        "bulk3_thickness",
        "bulk3_roughness",
        # "bulk3_sld",
        # "bulk3_thickness",
        # "bulk3_roughness",
        "oxide_sld",
        "oxide_thickness",
        "oxide_roughness",
+1 −2
Original line number Diff line number Diff line
#!/usr/bin/env python3
"""Train function for the transformer model."""
import os
import shutil
import torch
import mlflow
import logging
@@ -181,7 +180,7 @@ def train(
            mlflow.log_metric("test_loss", test_loss, step=epoch)

            # evaluate on real data
            system="cu"
            system = "mo"
            real_data_loss = real_data_evaluator.evaluate(
                model=model,
                device=device,
+35 −37
Original line number Diff line number Diff line
@@ -113,52 +113,50 @@ def generate_data(
    # )

    # mo_film, 5 layer
    # parameters_ref = np.column_stack(
    #     [
    #         np.random.uniform(-1.0, 7.0, n_dataset),  # electolyte_sld,  I changed the lower bound to -1 to include air and H2O
    #         np.random.uniform(5, 120, n_dataset),  # electolyte_roughness,

    #         np.random.uniform(-5.0, 6.5, n_dataset),  # sei_sld,
    #         np.random.uniform(10, 500, n_dataset),  # sei_thickness,
    #         np.random.uniform(1, 80, n_dataset),  # sei_roughness,

    #         np.random.uniform(-2, 7, n_dataset),  # bulk_3_sld,
    #         np.random.uniform(10, 200, n_dataset),  # material_thickness,
    #         np.random.uniform(1, 55, n_dataset),  # material_roughness,

    #         np.random.uniform(2, 6, n_dataset),  # bulk_2_sld,
    #         np.random.uniform(20, 700, n_dataset),  # cu_thickness,
    #         np.random.uniform(1, 55, n_dataset),  # cu_roughness,

    #         np.random.uniform(1, 4.2, n_dataset),  # oxide_sld,
    #         np.random.uniform(5, 50, n_dataset),  # oxide_thickness,
    #         np.random.uniform(1, 10, n_dataset),  # oxide_roughness,
    #     ]
    # )

    # xx_film, 6 layer model
    parameters_ref = np.column_stack(
        [
            np.random.uniform(-1.0, 7.0, n_dataset),  # electolyte_sld, including air and H2O
            np.random.uniform(
                -1.0, 7.0, n_dataset
            ),  # electolyte_sld,  I changed the lower bound to -1 to include air and H2O
            np.random.uniform(5, 120, n_dataset),  # electolyte_roughness,
            np.random.uniform(-5.0, 6.5, n_dataset),  # sei_sld,
            np.random.uniform(10, 500, n_dataset),  # sei_thickness,
            np.random.uniform(1, 80, n_dataset),  # sei_roughness,
            np.random.uniform(-2, 7, n_dataset),  # bulk_3_sld,
            np.random.uniform(10, 200, n_dataset),  # bulk_3_thickness,
            np.random.uniform(1, 55, n_dataset),  # bulk_3_roughness,
            np.random.uniform(2, 7, n_dataset),  # bulk_2_sld,
            np.random.uniform(20, 700, n_dataset),  # bulk_2_thickness (cu_thickness),
            np.random.uniform(1, 55, n_dataset),  # bulk_2_roughness (cu_roughness),
            np.random.uniform(-3.5, 7, n_dataset),  # bulk_1_sld,
            np.random.uniform(10, 200, n_dataset),  # bulk_1_thickness,
            np.random.uniform(1, 55, n_dataset),  # bulk_1_roughness,
            np.random.uniform(10, 200, n_dataset),  # material_thickness,
            np.random.uniform(1, 55, n_dataset),  # material_roughness,
            np.random.uniform(2, 6, n_dataset),  # bulk_2_sld,
            np.random.uniform(20, 700, n_dataset),  # cu_thickness,
            np.random.uniform(1, 55, n_dataset),  # cu_roughness,
            np.random.uniform(1, 4.2, n_dataset),  # oxide_sld,
            np.random.uniform(5, 50, n_dataset),  # oxide_thickness,
            np.random.uniform(1, 10, n_dataset),  # oxide_roughness,
        ]
    )

    # xx_film, 6 layer model
    # parameters_ref = np.column_stack(
    #     [
    #         np.random.uniform(-1.0, 7.0, n_dataset),  # electolyte_sld, including air and H2O
    #         np.random.uniform(5, 120, n_dataset),  # electolyte_roughness,
    #         np.random.uniform(-5.0, 6.5, n_dataset),  # sei_sld,
    #         np.random.uniform(10, 500, n_dataset),  # sei_thickness,
    #         np.random.uniform(1, 80, n_dataset),  # sei_roughness,
    #         np.random.uniform(-2, 7, n_dataset),  # bulk_3_sld,
    #         np.random.uniform(10, 200, n_dataset),  # bulk_3_thickness,
    #         np.random.uniform(1, 55, n_dataset),  # bulk_3_roughness,
    #         np.random.uniform(2, 7, n_dataset),  # bulk_2_sld,
    #         np.random.uniform(20, 700, n_dataset),  # bulk_2_thickness (cu_thickness),
    #         np.random.uniform(1, 55, n_dataset),  # bulk_2_roughness (cu_roughness),
    #         np.random.uniform(-3.5, 7, n_dataset),  # bulk_1_sld,
    #         np.random.uniform(10, 200, n_dataset),  # bulk_1_thickness,
    #         np.random.uniform(1, 55, n_dataset),  # bulk_1_roughness,
    #         np.random.uniform(1, 4.2, n_dataset),  # oxide_sld,
    #         np.random.uniform(5, 50, n_dataset),  # oxide_thickness,
    #         np.random.uniform(1, 10, n_dataset),  # oxide_roughness,
    #     ]
    # )

    # generate the reference rcurves
    r_curves = np.apply_along_axis(param_to_rcurve, 1, parameters_ref)
    logger.debug(f"r_curves.shape: {r_curves.shape}")
@@ -189,8 +187,8 @@ def param_to_rcurve(param: np.ndarray) -> np.ndarray:
        {"name": "SEI", "sld": param[2], "isld": 0, "thickness": param[3], "roughness": param[4]},
        {"name": "bulk3", "sld": param[5], "isld": 0, "thickness": param[6], "roughness": param[7]},
        {"name": "bulk2(Cu)", "sld": param[8], "isld": 0, "thickness": param[9], "roughness": param[10]},
        {"name": "bulk1", "sld": param[11], "isld": 0, "thickness": param[12], "roughness": param[13]},
        {"name": "oxide", "sld": param[14], "isld": 0, "thickness": param[15], "roughness": param[16]},
        {"name": "oxide", "sld": param[11], "isld": 0, "thickness": param[12], "roughness": param[13]},
        # {"name": "bulk1", "sld": param[14], "isld": 0, "thickness": param[15], "roughness": param[16]},
        {"name": "substrate", "sld": 2.07, "isld": 0, "thickness": 0, "roughness": 0},
    ]
    return r_generator(config)
@@ -215,8 +213,8 @@ def param_to_sld(param: np.ndarray) -> Tuple[np.ndarray, np.ndarray]:
        {"name": "SEI", "sld": param[2], "isld": 0, "thickness": param[3], "roughness": param[4]},
        {"name": "bulk3", "sld": param[5], "isld": 0, "thickness": param[6], "roughness": param[7]},
        {"name": "bulk2(Cu)", "sld": param[8], "isld": 0, "thickness": param[9], "roughness": param[10]},
        {"name": "bulk1", "sld": param[11], "isld": 0, "thickness": param[12], "roughness": param[13]},
        {"name": "oxide", "sld": param[14], "isld": 0, "thickness": param[15], "roughness": param[16]},
        {"name": "oxide", "sld": param[11], "isld": 0, "thickness": param[12], "roughness": param[13]},
        # {"name": "bulk1", "sld": param[14], "isld": 0, "thickness": param[15], "roughness": param[16]},
        {"name": "substrate", "sld": 2.07, "isld": 0, "thickness": 0, "roughness": 0},
    ]
    experiment = r_generator.build_experiment_from_config(config)