Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not exclude stresses from training #397

Open
FromColleWithLove opened this issue Apr 15, 2024 · 4 comments
Open

Can not exclude stresses from training #397

FromColleWithLove opened this issue Apr 15, 2024 · 4 comments

Comments

@FromColleWithLove
Copy link

I would like to train my model on forces and energies, excluding stresses. In my input.yaml i have:

input.yaml
[.....]
flare_calc:
gp: SGP_Wrapper
kernels:
- name: NormalizedDotProduct
sigma: 3.0
power: 2
descriptors:
- name: B2
nmax: 9
lmax: 3
cutoff_function: quadratic
radial_basis: chebyshev
cutoff_matrix: [[5.0]]
energy_training: True
force_training: True
stress_training: False
energy_noise: 0.3
forces_noise: 0.1
#stress_noise: 0.001
species:
- 13
single_atom_energies:
- 0
cutoff: 5.0
variance_type: local
max_iterations: 50
use_mapping: True
[.....]

This input worked well for trainings that include stresses, however, once I changed
stress_training: False
And commented the stress noise, I can not run the training. Instead I would get:
output

Traceback (most recent call last):
File "[...]/miniconda3/envs/envflare/bin/flare-otf", line 8, in
sys.exit(main())
File "[....]/flare/flare/scripts/otf_train.py", line 378, in main
fresh_start_otf(config)
File "[....]/flare/flare/scripts/otf_train.py", line 324, in fresh_start_otf
flare_calc, kernels = get_flare_calc(config["flare_calc"])
File "[....]/flare/flare/scripts/otf_train.py", line 99, in get_flare_calc
return get_sgp_calc(flare_config)
File "[....]/flare/flare/scripts/otf_train.py", line 295, in get_sgp_calc
sgp = SGP_Wrapper(
File "[.....]/flare/flare/bffs/sgp/sparse_gp.py", line 40, in __init__
self.sparse_gp = SparseGP(kernels, sigma_e, sigma_f, sigma_s)
TypeError: __init__(): incompatible constructor arguments. The following argument types are supported:
1. flare.bffs.sgp._C_flare.SparseGP()
2. flare.bffs.sgp._C_flare.SparseGP(arg0: List[flare.bffs.sgp._C_flare.Kernel], arg1: float, arg2: float, arg3: float)

Invoked with: [<flare.bffs.sgp._C_flare.NormalizedDotProduct object at 0x7f8465bdae30>], 0.3, 0.1, None

Information
FLARE version: 1.3.3

@anjohan
Copy link
Collaborator

anjohan commented Apr 16, 2024

Hi,

Based on the error message, it looks like this version of the code requires you to set the energy noise even if you're not training on stress.

@FromColleWithLove
Copy link
Author

FromColleWithLove commented Apr 17, 2024

@anjohan

Based on the error message, it looks like this version of the code requires you to set the energy noise even if you're not training on stress.

Did you mean stress noise?
Doing so would just train on stresses anyway. If I disable stress calculation in quantum espresso, and run the otf learning, I would get the classic:

raise PropertyNotImplementedError('{} not present in this '
ase.calculators.calculator.PropertyNotImplementedError: stress not present in this calculation

Re-enabling stress calculation, I would get a training on stress as well. I would get stresses predictions and mae on the output file anyway.

Maybe it would output those without using them, but I can not understand if that is the case. This "stress not present" gives me lots of doubts, why would you need it? For validation maybe?

@anjohan
Copy link
Collaborator

anjohan commented Apr 17, 2024

Sorry, yes, I meant the stress noise.

From what I can tell, it looks like it might work to set stress_training=False but still provide an arbitrary value for the stress noise.

if (stress is not None) and (self.stress_training):
structure_descriptor.stresses = stress

Note: I have no familiarity with the YAML file and SGP_Wrapper. We're working on new functionality for active learning directly in LAMMPS documented at https://bit.ly/flarelmpotf in case you want to be a test user.

@FromColleWithLove
Copy link
Author

@anjohan

I tried an offline training on a database I had which included stress tensors, and actually by setting
stress_training: False
and giving a placeholder stress noise value, i got different results and the stress noise wasn't changing, furthermore the likelihood gradient for the stress hyperparameter was always 0. I note that in the end the likelihood was slightly larger, yet also were errors, especially in the case of clusters (even though I expected stresses in large empty cells to be worse defined).

Also the potential made worse predictions, so I think I will keep stresses in there.

We're working on new functionality for active learning directly in LAMMPS documented at https://bit.ly/flarelmpotf in case you want to be a test user.

Really interesting. I will contact you about it, I don't think I can contribute with code but will be happy to help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants