Comments (15)
@davidleocadio it'll be something like this:
-
pull the latest
develop
--- I renamed something inStressOutput
to make this more consistant going forward. (Warning: this will break loading models trained withStressOutput
from before the change, but it's easy to fix if you need to--- let me know if you do.) -
make a
my-model-with-stress.yaml
that is a copy of your original config file -
add the
model_builders
fromminimal_stress.yaml
and theload_model_state
builder:model_builders: - SimpleIrrepsConfig - EnergyModel - PerSpeciesRescale - StressForceOutput - RescaleEnergyEtc - load_model_state load_model_state: /path/to/my/training_session/best_model.pth
the
load_model_state
builder takes the previously constructed model---which is the same as the one you trained, except substitutingStressForceOutput
forForceOutput
---and loads the weights from thestate_dict
found at the path given by theload_model_state
option. -
Deploy
my-model-with-stress.yaml
:$ nequip-deploy build --model my-model-with-stress.yaml deployed-stress.pth
from nequip.
Great! That's partially trained on forces, predicting stresses?
Looking at stress_dir.zip
I'm not sure I see the finite difference test you're talking about...
EDIT: I've added stress to the rescaling
from nequip.
Hi @keano130 ,
This should not be too hard to implement; the main thing is adding the displacement. (Since our edge vectors are calculated from positions + cell @ periodic_image_number
, they should be connected correctly in the autograd graph to displacements
if it is added to both positions
and cell
.)
This, and indicating to GradientOutput
that a cell must be present, can be done in a short StressOutput
module. I can write this up quickly if you are willing to help test it π
from nequip.
Thank you for the quick response, I am definitely willing to help test it.
from nequip.
@keano130 check out the https://github.com/mir-group/nequip/tree/stress branch, which contains a first stab at an implementation (untested so far)
from nequip.
Added some basic tests, the model does run and produce numbers for the stress when PBC are used. (See minimal-stress.yaml
.) Whether they're reasonable I can't really say.
One thing I'm not sure about is the multiplication conventions at https://github.com/mir-group/nequip/blob/stress/nequip/nn/_grad_output.py#L187. I had to modify them from the schnetpack
version, particularly for the positions, so I'm not sure if they make sense. Let me know what you think, and if the code works for you.
For running simple NPT simulations, the easiest thing to do would be to add the stress to the ASE calculator (dynamics/nequip_calculator.py
). This should be a pretty simple addition just involving some units stuff, and I'd happily accept a PR onto the stress
branch adding it.
from nequip.
The stress_key should to be added to the rescaleoutput layer , I tested the stresses using finite difference and this test passes correctly.
from nequip.
Furthermore, I compared the stress predictions of the network trained on ab initio (dft) generated data with the stress predictions of dft and they seemed to be relatively close (relative mean absolute error of 30%) which is very possible as the network was not yet fully trained.
from nequip.
Oh that's my bad, somehow i uploaded everything but the python file (I'm don't have my laptop with me, so I will upload it tomorrow, sorry for the delay)
from nequip.
Stress_test.zip
The 30% error was indeed trained on forces, predicting stress
from nequip.
Hi @keano130 ,
Wanted to let you know that stress is now being implemented in the stress-develop
branch off of the latest develop
β see PR #119. We hope to merge this soon after some more testing. The interface is similar to the previous stress
branch, but is cleaned up and updated to be based on the latest code.
from nequip.
Hi @keano130,
Just a heads up that I've gone ahead and merged the (now much more complete) stress-develop
branch into develop to end the merge hell that's starting to accumulate on that branch. Hopefully this makes it easier to use and test.
That said, stress support is still very much in beta and, as the warning I added says, please sanity check your results and let us know if you find things that seem strange or wrong.
from nequip.
Hi @Linux-cpp-lisp . I've checked out the develop branch and tried calculating stress with two different methods, both giving me a Key Error: 'stress' suggesting stress isn't an available option. Could you point me on how to calculate stress with a NequIP calculator? The most straightforward way I've tried it, which I thought should work is
`NN=nequip_calculator.NequIPCalculator
NN=NN.from_deployed_model(model_path="./deployedstress.pth", \
species_to_type_name = {
"Cu": "Cu",
})
CU=Atoms('Cu',positions=[(0, 0, 0),\
(0.0*a, 0.5*a, 0.5*a),\
(0.5*a, 0*a, 0.5*a),\
(0.5*a, 0.5*a, 0*a)],\
cell=[1*a,1*a,1*a],pbc=True)
NN.calculate(atoms=CU,properties=["energy","forces","stress"])
print(NN.results)
Giving an error such as
stress = out[AtomicDataDict.STRESS_KEY].detach().cpu().numpy()
KeyError: 'stress'
Similarily adding the calculator to an Atoms object and running get_stress() doesn't work with the same error.
from nequip.
@davidleocadio does your model include a StressForceOutput
? The model must be built to calculate stresses for the calculator to be able to get those outputs. See minimal_stress.yaml
for an example of this in model_builders
.
The good news is that if it doesn't, you can still reuse your trained weights an build a new model with a StressForceOutput
that just loads the weights from your trained model without it. If this is the case let me know and I will show you how.
from nequip.
@Linux-cpp-lisp great thanks. I wasn't aware of minimal_stress.yaml.
However, I think the second option you mention where one uses the weights from a previously trained model would be very useful. Would you mind showing how one should do this?
from nequip.
Related Issues (20)
- π [FEATURE]How to Train and Validate on Separate Datasets HOT 2
- How to do custom EarlyStopping?β [QUESTION] HOT 4
- β [QUESTION]
- β [QUESTION] About the data class AtomicData HOT 3
- bugs with "initialize_from_state"π [BUG] HOT 5
- how to choose nosehoover the value of nvt_qβ [QUESTION]
- β [QUESTION]Finetuning Validation Error Higher than Pre-training Error in Nequip HOT 1
- Confusion about `num_frames` attribute in `HDF5Dataset` HOT 1
- β [QUESTION]how can I use the ase calculator for testing ?
- What is the unit of virialsβ [QUESTION] HOT 3
- MLFF for Silicon HOT 1
- minimal extxyz HOT 2
- β [QUESTION] cannot repeat the RMSE of water dataset
- π [FEATURE] Custom properties HOT 1
- π [BUG] Using initialize_from_state HOT 3
- Default Units in the outputs of training HOT 1
- β [QUESTION] How to use hdf5 dataset in config files?
- π [BUG] `InvalidVersion` in v0.6.0 HOT 3
- π [BUG] Colab link broken HOT 1
- [Duplicate BUG] Google Colab link isn't accessible HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nequip.