flare icon indicating copy to clipboard operation
flare copied to clipboard

OTF: "calculate_energy" or "calculate_efs" variables are not saved to the checkpoint

Open aaronchen0316 opened this issue 3 years ago • 1 comments

Describe the bug calculate_energy and calculate_efs are not instance variables. When the OTF object is saved as dictionary/checkpoint, these two variables are not saved. Therefore, when restarting from the checkpoint, self.pred_func will be initialized as predict_on_structure or predict_on_structure_par. Later compute_mae() will throw a NoneType operation error since GP doesn't calculate the efs after restarting from checkpoint.

To Reproduce Steps to reproduce the behavior: set calculate_energy or calculate_efs to True and force_only to False. Run OTF and save it to checkpoint. Restart from checkpoint. When a new DFT is called, the compute_mae() throws an error:

otf.py", line 507, in compute_mae
    e_mae = np.mean(np.abs(dft_energy - gp_energy))
TypeError: unsupported operand type(s) for -: 'NoneType' and 'NoneType'

Expected behavior calculate_energy and calculate_efs are defined as instance variable.

Screenshots N/A

aaronchen0316 avatar Aug 09 '22 16:08 aaronchen0316

@aaronchen0316 , thanks for reporting this, and sorry for the late response because I'm recently traveling. If you have an idea how to resolve it (e.g. adding the variables in the dict), you can open up a pull request and I'll review it. Otherwise, I'll take a look at this, but might get back to you after August.

YuuuXie avatar Aug 15 '22 02:08 YuuuXie