def test_from_mvl_models(self): with ScratchDir("."): model = MEGNetModel.from_mvl_models("Eform_MP_2019") li2o = self.get_structure("Li2O") self.assertAlmostEqual(float(model.predict_structure(li2o)), -2.0152957439422607, places=4)
# Data preprocessing: # Load binary compounds' formation energies example data, # then split into training and validation subsets. full_df = load_data("binary_e_form") num_training = int(TRAINING_RATIO * len(full_df.index)) train_df = full_df[:num_training] val_df = full_df[num_training:] # 4217 training samples, 1055 validation samples. train_structs = train_df["structure"] val_structs = val_df["structure"] train_targets = train_df["formation_energy_per_atom"] val_targets = val_df["formation_energy_per_atom"] # 1. Load MEGNetModel meg_model = MEGNetModel.from_mvl_models("Eform_MP_2019") # 2. Make probabilistic model # Specify Kullback-Leibler divergence weighting in loss function: kl_weight = BATCH_SIZE / num_training # Then make the model: prob_model = MEGNetProbModel( meg_model=meg_model, num_inducing_points=NUM_INDUCING_POINTS, kl_weight=kl_weight, ) def train_model(): """Train and save the probabilistic model.""" prob_model.train(