Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- .gitattributes+1
- 2_training/forces/_phonopy_freqs.jsonAdded+1
- 2_training/forces/diamond_ase_ref.nequip.pt2Added+3
- 2_training/forces/phonon_comparison.pngAdded
- 2_training/forces/train_force.logAdded+38
- 2_training/hamiltonian/infer_sc/dataset/00/overlaps.h5Added+3
- 2_training/hamiltonian/infer_uc/dataset/00/element.datAdded+2
- 2_training/hamiltonian/infer_uc/dataset/00/graph.pklAdded+3
- 2_training/hamiltonian/infer_uc/dataset/00/hamiltonians.h5Added+3
- 2_training/hamiltonian/infer_uc/dataset/00/hamiltonians_pred.h5Added+3
- 2_training/hamiltonian/infer_uc/dataset/00/info.jsonAdded+1
- 2_training/hamiltonian/infer_uc/dataset/00/lat.datAdded+3
- 2_training/hamiltonian/infer_uc/dataset/00/orbital_types.datAdded+2
- 2_training/hamiltonian/infer_uc/dataset/00/overlaps.h5Added+3
- 2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/config.iniAdded+82
- 2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/result.txtAdded+86
- 2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/__init__.pyAdded+10
- 2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/__pycache__/__init__.cpython-312.pycAdded
- 2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/__pycache__/data.cpython-312.pycAdded
- 2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/__pycache__/graph.cpython-312.pycAdded
- 2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/__pycache__/kernel.cpython-312.pycAdded
- 2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/__pycache__/model.cpython-312.pycAdded
- 2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/__pycache__/rotate.cpython-312.pycAdded
- 2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/__pycache__/utils.cpython-312.pycAdded
- 2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/data.pyAdded+217
- 2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/default.iniAdded+88
- 2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_HermNet/__init__.pyAdded+1
- 2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_HermNet/__pycache__/__init__.cpython-312.pycAdded
- 2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_HermNet/__pycache__/rmnet.cpython-312.pycAdded
- 2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_HermNet/license.txtAdded+1
- 2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_HermNet/rmnet.pyAdded+105
- 2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/__init__.pyAdded+2
- 2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/__pycache__/__init__.cpython-312.pycAdded
- 2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/__pycache__/diff_group_norm.cpython-312.pycAdded
- 2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/__pycache__/graph_norm.cpython-312.pycAdded
- 2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/diff_group_norm.pyAdded+109
- 2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/graph_norm.pyAdded+60
- 2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/license.txtAdded+22
- 2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_pymatgen/__init__.pyAdded+1
- 2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_pymatgen/__pycache__/__init__.cpython-312.pycAdded
- 2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_pymatgen/__pycache__/lattice.cpython-312.pycAdded
- 2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_pymatgen/lattice.pyAdded+71
- 2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_pymatgen/license.txtAdded+22
- 2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_schnetpack/__init__.pyAdded+1
- 2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_schnetpack/__pycache__/__init__.cpython-312.pycAdded
- 2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_schnetpack/__pycache__/acsf.cpython-312.pycAdded
- 2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_schnetpack/acsf.pyAdded+50
- 2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_schnetpack/license.txtAdded+35
- 2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_se3_transformer/__init__.pyAdded+1
- 2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_se3_transformer/__pycache__/__init__.cpython-312.pycAdded
229 unmodified lines230231232229 unmodified lines1_data_prepare/data/disp-14/scf/diamond.save/charge-density.dat filter=lfs diff=lfs merge=lfs -text1_data_prepare/data/disp-07/scf/VSC filter=lfs diff=lfs merge=lfs -text1_data_prepare/data/disp-07/scf/diamond.save/charge-density.dat filter=lfs diff=lfs merge=lfs -text229 unmodified lines230231232233229 unmodified lines1_data_prepare/data/disp-14/scf/diamond.save/charge-density.dat filter=lfs diff=lfs merge=lfs -text1_data_prepare/data/disp-07/scf/VSC filter=lfs diff=lfs merge=lfs -text1_data_prepare/data/disp-07/scf/diamond.save/charge-density.dat filter=lfs diff=lfs merge=lfs -text2_training/forces/diamond_ase_ref.nequip.pt2 filter=lfs diff=lfs merge=lfs -text
1{"freqs_thz": [-6.176924148037084e-06, -6.167703510703962e-06, -6.1374103546125556e-06, 38.86256568564987, 38.86256568564988, 38.86256568564988]}123version https://git-lfs.github.com/spec/v1oid sha256:05a8ffd2d4feb583ae3c0f31b67e811967895e9b3390058a7c1a653e229bc8cdsize 102893381234567891011121314151617181920212223242526272829303132333435363738Step 1: Building forces dataset... Dataset exists: /home/apolyukhin/Development/epc_ml/example/diamond/2_training/forces/dataset.xyz
Step 2: Running DFPT at q=Gamma... DFPT output exists: /home/apolyukhin/Development/epc_ml/example/diamond/2_training/forces/dfpt/ph.out
Step 3: NequIP training... --skip-training: using existing checkpoint: /home/apolyukhin/Development/epc_ml/example/diamond/2_training/forces/outputs/2026-03-03/13-29-04/best.ckpt
Step 4: Compiling model... Compiled model exists: /home/apolyukhin/Development/epc_ml/example/diamond/2_training/forces/diamond_ase.nequip.pth
Step 5: Running phonopy + NequIP at Gamma... Running phonopy + NequIP in deeph env .../home/apolyukhin/Development/epc_ml/example/diamond/2_training/forces/_phonopy_launcher.py:28: DeprecationWarning: PhonopyAtoms.get_chemical_symbols() is deprecated. Use symbols attribute instead. a = Atoms(symbols=sc.get_chemical_symbols(),/home/apolyukhin/Development/epc_ml/example/diamond/2_training/forces/_phonopy_launcher.py:29: DeprecationWarning: PhonopyAtoms.get_positions() is deprecated. Use positions attribute instead. positions=sc.get_positions(),/home/apolyukhin/Development/epc_ml/example/diamond/2_training/forces/_phonopy_launcher.py:30: DeprecationWarning: PhonopyAtoms.get_cell() is deprecated. Use cell attribute instead. cell=sc.get_cell(), pbc=True) Phonopy: 1 displacements (128 atoms each) [1/1] |F|max=0.3194 eV/A Gamma freqs written to /home/apolyukhin/Development/epc_ml/example/diamond/2_training/forces/_phonopy_freqs.json
Step 6: Comparing phonons... Mode DFPT (THz) DFPT (cm-1) ML (THz) ML (cm-1) Err (cm-1)----------------------------------------------------------------- 1 6.9242 230.97 -0.0000 -0.00 -230.97 2 6.9242 230.97 -0.0000 -0.00 -230.97 3 6.9242 230.97 -0.0000 -0.00 -230.97 4 40.9717 1366.67 38.8626 1296.32 -70.35 5 40.9717 1366.67 38.8626 1296.32 -70.35 6 40.9717 1366.67 38.8626 1296.32 -70.35
Optical: DFPT=23.95 THz, ML=38.86 THz, err=+62.3% Saved: /home/apolyukhin/Development/epc_ml/example/diamond/2_training/forces/phonon_comparison.png
train_force.py done.123version https://git-lfs.github.com/spec/v1oid sha256:69f8fb67509a2908d6fbcdc098aa26a8a4af716b76aebda4ff04b872cba43859size 3986765126 6 123version https://git-lfs.github.com/spec/v1oid sha256:589308142f311a9e1f063af5f5db20bb434be2fb921ab1a5a1fb8da79b2dadc8size 8317809123version https://git-lfs.github.com/spec/v1oid sha256:606d2f8997a1fb3ee3847fcb1a519ee249f8a7e88d323b694daf7858ab43943dsize 558800123version https://git-lfs.github.com/spec/v1oid sha256:cf17707c62b11e50879ce078e8582ca30180d512206b2f5fc52deee5f2faa823size 5196001{"isspinful": false}1230.000000000000000000e+00 1.783499998856923785e+00 1.783499998856923785e+001.783499998856923785e+00 0.000000000000000000e+00 1.783499998856923785e+001.783499998856923785e+00 1.783499998856923785e+00 0.000000000000000000e+00120 0 1 1 20 0 1 1 2123version https://git-lfs.github.com/spec/v1oid sha256:fb1a42ebec020dbdbe6e8b9e8ece9f70d737db9e5e6108003c759c0baad85c3dsize 49988812345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182[basic]graph_dir = /home/apolyukhin/scripts/ml/diamond-qe/deeph-data/graphsave_dir = /home/apolyukhin/scripts/ml/diamond-qe/pristine-uc/reconstruction/aohamiltonian/pred_ham_stdraw_dir = /home/apolyukhin/scripts/ml/diamond-qe/deeph-data/preprocessdataset_name = diamond_qeonly_get_graph = Falseinterface = h5target = hamiltoniandisable_cuda = Truedevice = cpunum_threads = -1save_to_time_folder = Falsesave_csv = Truetb_writer = Falseseed = 42multiprocessing = 0orbital = [{"6 6": [0, 0]}, {"6 6": [0, 1]}, {"6 6": [0, 2]}, {"6 6": [0, 3]}, {"6 6": [0, 4]}, {"6 6": [0, 5]}, {"6 6": [0, 6]}, {"6 6": [0, 7]}, {"6 6": [0, 8]}, {"6 6": [0, 9]}, {"6 6": [0, 10]}, {"6 6": [0, 11]}, {"6 6": [0, 12]}, {"6 6": [1, 0]}, {"6 6": [1, 1]}, {"6 6": [1, 2]}, {"6 6": [1, 3]}, {"6 6": [1, 4]}, {"6 6": [1, 5]}, {"6 6": [1, 6]}, {"6 6": [1, 7]}, {"6 6": [1, 8]}, {"6 6": [1, 9]}, {"6 6": [1, 10]}, {"6 6": [1, 11]}, {"6 6": [1, 12]}, {"6 6": [2, 0]}, {"6 6": [2, 1]}, {"6 6": [2, 2]}, {"6 6": [2, 3]}, {"6 6": [2, 4]}, {"6 6": [2, 5]}, {"6 6": [2, 6]}, {"6 6": [2, 7]}, {"6 6": [2, 8]}, {"6 6": [2, 9]}, {"6 6": [2, 10]}, {"6 6": [2, 11]}, {"6 6": [2, 12]}, {"6 6": [3, 0]}, {"6 6": [3, 1]}, {"6 6": [3, 2]}, {"6 6": [3, 3]}, {"6 6": [3, 4]}, {"6 6": [3, 5]}, {"6 6": [3, 6]}, {"6 6": [3, 7]}, {"6 6": [3, 8]}, {"6 6": [3, 9]}, {"6 6": [3, 10]}, {"6 6": [3, 11]}, {"6 6": [3, 12]}, {"6 6": [4, 0]}, {"6 6": [4, 1]}, {"6 6": [4, 2]}, {"6 6": [4, 3]}, {"6 6": [4, 4]}, {"6 6": [4, 5]}, {"6 6": [4, 6]}, {"6 6": [4, 7]}, {"6 6": [4, 8]}, {"6 6": [4, 9]}, {"6 6": [4, 10]}, {"6 6": [4, 11]}, {"6 6": [4, 12]}, {"6 6": [5, 0]}, {"6 6": [5, 1]}, {"6 6": [5, 2]}, {"6 6": [5, 3]}, {"6 6": [5, 4]}, {"6 6": [5, 5]}, {"6 6": [5, 6]}, {"6 6": [5, 7]}, {"6 6": [5, 8]}, {"6 6": [5, 9]}, {"6 6": [5, 10]}, {"6 6": [5, 11]}, {"6 6": [5, 12]}, {"6 6": [6, 0]}, {"6 6": [6, 1]}, {"6 6": [6, 2]}, {"6 6": [6, 3]}, {"6 6": [6, 4]}, {"6 6": [6, 5]}, {"6 6": [6, 6]}, {"6 6": [6, 7]}, {"6 6": [6, 8]}, {"6 6": [6, 9]}, {"6 6": [6, 10]}, {"6 6": [6, 11]}, {"6 6": [6, 12]}, {"6 6": [7, 0]}, {"6 6": [7, 1]}, {"6 6": [7, 2]}, {"6 6": [7, 3]}, {"6 6": [7, 4]}, {"6 6": [7, 5]}, {"6 6": [7, 6]}, {"6 6": [7, 7]}, {"6 6": [7, 8]}, {"6 6": [7, 9]}, {"6 6": [7, 10]}, {"6 6": [7, 11]}, {"6 6": [7, 12]}, {"6 6": [8, 0]}, {"6 6": [8, 1]}, {"6 6": [8, 2]}, {"6 6": [8, 3]}, {"6 6": [8, 4]}, {"6 6": [8, 5]}, {"6 6": [8, 6]}, {"6 6": [8, 7]}, {"6 6": [8, 8]}, {"6 6": [8, 9]}, {"6 6": [8, 10]}, {"6 6": [8, 11]}, {"6 6": [8, 12]}, {"6 6": [9, 0]}, {"6 6": [9, 1]}, {"6 6": [9, 2]}, {"6 6": [9, 3]}, {"6 6": [9, 4]}, {"6 6": [9, 5]}, {"6 6": [9, 6]}, {"6 6": [9, 7]}, {"6 6": [9, 8]}, {"6 6": [9, 9]}, {"6 6": [9, 10]}, {"6 6": [9, 11]}, {"6 6": [9, 12]}, {"6 6": [10, 0]}, {"6 6": [10, 1]}, {"6 6": [10, 2]}, {"6 6": [10, 3]}, {"6 6": [10, 4]}, {"6 6": [10, 5]}, {"6 6": [10, 6]}, {"6 6": [10, 7]}, {"6 6": [10, 8]}, {"6 6": [10, 9]}, {"6 6": [10, 10]}, {"6 6": [10, 11]}, {"6 6": [10, 12]}, {"6 6": [11, 0]}, {"6 6": [11, 1]}, {"6 6": [11, 2]}, {"6 6": [11, 3]}, {"6 6": [11, 4]}, {"6 6": [11, 5]}, {"6 6": [11, 6]}, {"6 6": [11, 7]}, {"6 6": [11, 8]}, {"6 6": [11, 9]}, {"6 6": [11, 10]}, {"6 6": [11, 11]}, {"6 6": [11, 12]}, {"6 6": [12, 0]}, {"6 6": [12, 1]}, {"6 6": [12, 2]}, {"6 6": [12, 3]}, {"6 6": [12, 4]}, {"6 6": [12, 5]}, {"6 6": [12, 6]}, {"6 6": [12, 7]}, {"6 6": [12, 8]}, {"6 6": [12, 9]}, {"6 6": [12, 10]}, {"6 6": [12, 11]}, {"6 6": [12, 12]}]o_component = Henergy_component = summationmax_element = -1statistics = Falsenormalizer = Falseboxcox = False
[graph]radius = -1.0max_num_nbr = 0create_from_dft = Trueif_lcmp_graph = Trueseparate_onsite = Falsenew_sp = False
[train]epochs = 5000pretrained = resume = train_ratio = 0.6val_ratio = 0.2test_ratio = 0.2early_stopping_loss = 0.0early_stopping_loss_epoch = [0.000000, 500]revert_then_decay = Truerevert_threshold = 30revert_decay_epoch = [800, 2000, 3000, 4000]revert_decay_gamma = [0.4, 0.5, 0.5, 0.4]clip_grad = Trueclip_grad_value = 4.2switch_sgd = Falseswitch_sgd_lr = 1e-4switch_sgd_epoch = -1
[hyperparameter]batch_size = 1dtype = float32optimizer = adamlearning_rate = 0.001lr_scheduler = lr_milestones = []momentum = 0.9weight_decay = 0criterion = MaskMSELossretain_edge_fea = Truelambda_eij = 0.0lambda_ei = 0.1lambda_etot = 0.0
[network]atom_fea_len = 64edge_fea_len = 128gauss_stop = 6.0num_l = 4aggr = adddistance_expansion = GaussianBasisif_exp = Trueif_multiplelinear = Falseif_edge_update = Trueif_lcmp = Truenormalization = LayerNormatom_update_net = PAINNtrainable_gaussians = Falsetype_affine = False
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586====== CONFIG ======[basic]graph_dir=/home/apolyukhin/scripts/ml/diamond-qe/deeph-data/graphsave_dir=/home/apolyukhin/scripts/ml/diamond-qe/pristine-uc/reconstruction/aohamiltonian/pred_ham_stdraw_dir=/home/apolyukhin/scripts/ml/diamond-qe/deeph-data/preprocessdataset_name=diamond_qeonly_get_graph=Falseinterface=h5target=hamiltoniandisable_cuda=Truedevice=cpunum_threads=-1save_to_time_folder=Falsesave_csv=Truetb_writer=Falseseed=42multiprocessing=0orbital=[{"6 6": [0, 0]}, {"6 6": [0, 1]}, {"6 6": [0, 2]}, {"6 6": [0, 3]}, {"6 6": [0, 4]}, {"6 6": [0, 5]}, {"6 6": [0, 6]}, {"6 6": [0, 7]}, {"6 6": [0, 8]}, {"6 6": [0, 9]}, {"6 6": [0, 10]}, {"6 6": [0, 11]}, {"6 6": [0, 12]}, {"6 6": [1, 0]}, {"6 6": [1, 1]}, {"6 6": [1, 2]}, {"6 6": [1, 3]}, {"6 6": [1, 4]}, {"6 6": [1, 5]}, {"6 6": [1, 6]}, {"6 6": [1, 7]}, {"6 6": [1, 8]}, {"6 6": [1, 9]}, {"6 6": [1, 10]}, {"6 6": [1, 11]}, {"6 6": [1, 12]}, {"6 6": [2, 0]}, {"6 6": [2, 1]}, {"6 6": [2, 2]}, {"6 6": [2, 3]}, {"6 6": [2, 4]}, {"6 6": [2, 5]}, {"6 6": [2, 6]}, {"6 6": [2, 7]}, {"6 6": [2, 8]}, {"6 6": [2, 9]}, {"6 6": [2, 10]}, {"6 6": [2, 11]}, {"6 6": [2, 12]}, {"6 6": [3, 0]}, {"6 6": [3, 1]}, {"6 6": [3, 2]}, {"6 6": [3, 3]}, {"6 6": [3, 4]}, {"6 6": [3, 5]}, {"6 6": [3, 6]}, {"6 6": [3, 7]}, {"6 6": [3, 8]}, {"6 6": [3, 9]}, {"6 6": [3, 10]}, {"6 6": [3, 11]}, {"6 6": [3, 12]}, {"6 6": [4, 0]}, {"6 6": [4, 1]}, {"6 6": [4, 2]}, {"6 6": [4, 3]}, {"6 6": [4, 4]}, {"6 6": [4, 5]}, {"6 6": [4, 6]}, {"6 6": [4, 7]}, {"6 6": [4, 8]}, {"6 6": [4, 9]}, {"6 6": [4, 10]}, {"6 6": [4, 11]}, {"6 6": [4, 12]}, {"6 6": [5, 0]}, {"6 6": [5, 1]}, {"6 6": [5, 2]}, {"6 6": [5, 3]}, {"6 6": [5, 4]}, {"6 6": [5, 5]}, {"6 6": [5, 6]}, {"6 6": [5, 7]}, {"6 6": [5, 8]}, {"6 6": [5, 9]}, {"6 6": [5, 10]}, {"6 6": [5, 11]}, {"6 6": [5, 12]}, {"6 6": [6, 0]}, {"6 6": [6, 1]}, {"6 6": [6, 2]}, {"6 6": [6, 3]}, {"6 6": [6, 4]}, {"6 6": [6, 5]}, {"6 6": [6, 6]}, {"6 6": [6, 7]}, {"6 6": [6, 8]}, {"6 6": [6, 9]}, {"6 6": [6, 10]}, {"6 6": [6, 11]}, {"6 6": [6, 12]}, {"6 6": [7, 0]}, {"6 6": [7, 1]}, {"6 6": [7, 2]}, {"6 6": [7, 3]}, {"6 6": [7, 4]}, {"6 6": [7, 5]}, {"6 6": [7, 6]}, {"6 6": [7, 7]}, {"6 6": [7, 8]}, {"6 6": [7, 9]}, {"6 6": [7, 10]}, {"6 6": [7, 11]}, {"6 6": [7, 12]}, {"6 6": [8, 0]}, {"6 6": [8, 1]}, {"6 6": [8, 2]}, {"6 6": [8, 3]}, {"6 6": [8, 4]}, {"6 6": [8, 5]}, {"6 6": [8, 6]}, {"6 6": [8, 7]}, {"6 6": [8, 8]}, {"6 6": [8, 9]}, {"6 6": [8, 10]}, {"6 6": [8, 11]}, {"6 6": [8, 12]}, {"6 6": [9, 0]}, {"6 6": [9, 1]}, {"6 6": [9, 2]}, {"6 6": [9, 3]}, {"6 6": [9, 4]}, {"6 6": [9, 5]}, {"6 6": [9, 6]}, {"6 6": [9, 7]}, {"6 6": [9, 8]}, {"6 6": [9, 9]}, {"6 6": [9, 10]}, {"6 6": [9, 11]}, {"6 6": [9, 12]}, {"6 6": [10, 0]}, {"6 6": [10, 1]}, {"6 6": [10, 2]}, {"6 6": [10, 3]}, {"6 6": [10, 4]}, {"6 6": [10, 5]}, {"6 6": [10, 6]}, {"6 6": [10, 7]}, {"6 6": [10, 8]}, {"6 6": [10, 9]}, {"6 6": [10, 10]}, {"6 6": [10, 11]}, {"6 6": [10, 12]}, {"6 6": [11, 0]}, {"6 6": [11, 1]}, {"6 6": [11, 2]}, {"6 6": [11, 3]}, {"6 6": [11, 4]}, {"6 6": [11, 5]}, {"6 6": [11, 6]}, {"6 6": [11, 7]}, {"6 6": [11, 8]}, {"6 6": [11, 9]}, {"6 6": [11, 10]}, {"6 6": [11, 11]}, {"6 6": [11, 12]}, {"6 6": [12, 0]}, {"6 6": [12, 1]}, {"6 6": [12, 2]}, {"6 6": [12, 3]}, {"6 6": [12, 4]}, {"6 6": [12, 5]}, {"6 6": [12, 6]}, {"6 6": [12, 7]}, {"6 6": [12, 8]}, {"6 6": [12, 9]}, {"6 6": [12, 10]}, {"6 6": [12, 11]}, {"6 6": [12, 12]}]o_component=Henergy_component=summationmax_element=-1statistics=Falsenormalizer=Falseboxcox=False
[graph]radius=-1.0max_num_nbr=0create_from_dft=Trueif_lcmp_graph=Trueseparate_onsite=Falsenew_sp=False
[train]epochs=5000pretrained=resume=train_ratio=0.6val_ratio=0.2test_ratio=0.2early_stopping_loss=0.0early_stopping_loss_epoch=[0.000000, 500]revert_then_decay=Truerevert_threshold=30revert_decay_epoch=[800, 2000, 3000, 4000]revert_decay_gamma=[0.4, 0.5, 0.5, 0.4]clip_grad=Trueclip_grad_value=4.2switch_sgd=Falseswitch_sgd_lr=1e-4switch_sgd_epoch=-1
[hyperparameter]batch_size=1dtype=float32optimizer=adamlearning_rate=0.001lr_scheduler=lr_milestones=[]momentum=0.9weight_decay=0criterion=MaskMSELossretain_edge_fea=Truelambda_eij=0.0lambda_ei=0.1lambda_etot=0.0
[network]atom_fea_len=64edge_fea_len=128gauss_stop=6.0num_l=4aggr=adddistance_expansion=GaussianBasisif_exp=Trueif_multiplelinear=Falseif_edge_update=Trueif_lcmp=Truenormalization=LayerNormatom_update_net=PAINNtrainable_gaussians=Falsetype_affine=False
=> load best checkpoint (epoch 3217)=> Atomic types: [6], spinful: False, the number of atomic types: 1.Save processed graph to /home/apolyukhin/scripts/ml/diamond-qe/pristine-uc/reconstruction/aohamiltonian/graph.pkl, cost 0.1220557689666748 seconds12345678910from .data import HDatafrom .model import HGNN, ExpBernsteinBasisfrom .utils import print_args, Logger, MaskMSELoss, MaskMAELoss, write_ham_npz, write_ham, write_ham_h5, get_config, \ get_inference_config, get_preprocess_configfrom .graph import Collater, collate_fn, get_graph, load_orbital_typesfrom .kernel import DeepHKernelfrom .preprocess import get_rc, OijLoad, GetEEiEij, abacus_parse, siesta_parsefrom .rotate import get_rh, rotate_back, Rotate, dtype_dict
__version__ = "0.2.2"123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217import warningsimport osimport timeimport tqdm
from pymatgen.core.structure import Structureimport numpy as npimport torchfrom torch_geometric.data import InMemoryDatasetfrom pathos.multiprocessing import ProcessingPool as Pool
from .graph import get_graph
class HData(InMemoryDataset): def __init__(self, raw_data_dir: str, graph_dir: str, interface: str, target: str, dataset_name: str, multiprocessing: int, radius, max_num_nbr, num_l, max_element, create_from_DFT, if_lcmp_graph, separate_onsite, new_sp, default_dtype_torch, nums: int = None, transform=None, pre_transform=None, pre_filter=None): """when interface == 'h5',raw_data_dir├── 00│ ├──rh.h5 / rdm.h5│ ├──rc.h5│ ├──element.dat│ ├──orbital_types.dat│ ├──site_positions.dat│ ├──lat.dat│ └──info.json├── 01│ ├──rh.h5 / rdm.h5│ ├──rc.h5│ ├──element.dat│ ├──orbital_types.dat│ ├──site_positions.dat│ ├──lat.dat│ └──info.json├── 02│ ├──rh.h5 / rdm.h5│ ├──rc.h5│ ├──element.dat│ ├──orbital_types.dat│ ├──site_positions.dat│ ├──lat.dat│ └──info.json├── ... """ self.raw_data_dir = raw_data_dir assert dataset_name.find('-') == -1, '"-" can not be included in the dataset name' if create_from_DFT: way_create_graph = 'FromDFT' else: way_create_graph = f'{radius}r{max_num_nbr}mn' if if_lcmp_graph: lcmp_str = f'{num_l}l' else: lcmp_str = 'WithoutLCMP' if separate_onsite is True: onsite_str = '-SeparateOnsite' else: onsite_str = '' if new_sp: new_sp_str = '-NewSP' else: new_sp_str = '' if target == 'hamiltonian': title = 'HGraph' else: raise ValueError('Unknown prediction target: {}'.format(target)) graph_file_name = f'{title}-{interface}-{dataset_name}-{lcmp_str}-{way_create_graph}{onsite_str}{new_sp_str}.pkl' self.data_file = os.path.join(graph_dir, graph_file_name) os.makedirs(graph_dir, exist_ok=True) self.data, self.slices = None, None self.interface = interface self.target = target self.dataset_name = dataset_name self.multiprocessing = multiprocessing self.radius = radius self.max_num_nbr = max_num_nbr self.num_l = num_l self.create_from_DFT = create_from_DFT self.if_lcmp_graph = if_lcmp_graph self.separate_onsite = separate_onsite self.new_sp = new_sp self.default_dtype_torch = default_dtype_torch
self.nums = nums self.transform = transform self.pre_transform = pre_transform self.pre_filter = pre_filter self.__indices__ = None self.__data_list__ = None self._indices = None self._data_list = None
print(f'Graph data file: {graph_file_name}') if os.path.exists(self.data_file): print('Use existing graph data file') else: print('Process new data file......') self.process() begin = time.time() try: loaded_data = torch.load(self.data_file) except AttributeError: raise RuntimeError('Error in loading graph data file, try to delete it and generate the graph file with the current version of PyG') if len(loaded_data) == 2: warnings.warn('You are using the graph data file with an old version') self.data, self.slices = loaded_data self.info = { "spinful": False, "index_to_Z": torch.arange(max_element + 1), "Z_to_index": torch.arange(max_element + 1), } elif len(loaded_data) == 3: self.data, self.slices, tmp = loaded_data if isinstance(tmp, dict): self.info = tmp print(f"Atomic types: {self.info['index_to_Z'].tolist()}") else: warnings.warn('You are using an old version of the graph data file') self.info = { "spinful": tmp, "index_to_Z": torch.arange(max_element + 1), "Z_to_index": torch.arange(max_element + 1), } print(f'Finish loading the processed {len(self)} structures (spinful: {self.info["spinful"]}, ' f'the number of atomic types: {len(self.info["index_to_Z"])}), cost {time.time() - begin:.0f} seconds')
def process_worker(self, folder, **kwargs): stru_id = os.path.split(folder)[-1]
structure = Structure(np.loadtxt(os.path.join(folder, 'lat.dat')).T, np.loadtxt(os.path.join(folder, 'element.dat')), np.loadtxt(os.path.join(folder, 'site_positions.dat')).T, coords_are_cartesian=True, to_unit_cell=False)
cart_coords = torch.tensor(structure.cart_coords, dtype=self.default_dtype_torch) frac_coords = torch.tensor(structure.frac_coords, dtype=self.default_dtype_torch) numbers = torch.tensor(structure.atomic_numbers) structure.lattice.matrix.setflags(write=True) lattice = torch.tensor(structure.lattice.matrix, dtype=self.default_dtype_torch) if self.target == 'E_ij': huge_structure = True else: huge_structure = False return get_graph(cart_coords, frac_coords, numbers, stru_id, r=self.radius, max_num_nbr=self.max_num_nbr, numerical_tol=1e-8, lattice=lattice, default_dtype_torch=self.default_dtype_torch, tb_folder=folder, interface=self.interface, num_l=self.num_l, create_from_DFT=self.create_from_DFT, if_lcmp_graph=self.if_lcmp_graph, separate_onsite=self.separate_onsite, target=self.target, huge_structure=huge_structure, if_new_sp=self.new_sp, **kwargs)
def process(self): begin = time.time() folder_list = [] for root, dirs, files in os.walk(self.raw_data_dir): if (self.interface == 'h5' and 'rc.h5' in files) or ( self.interface == 'npz' and 'rc.npz' in files): folder_list.append(root) folder_list = sorted(folder_list) folder_list = folder_list[: self.nums] if self.dataset_name == 'graphene_450': folder_list = folder_list[500:5000:10] if self.dataset_name == 'graphene_1500': folder_list = folder_list[500:5000:3] if self.dataset_name == 'bp_bilayer': folder_list = folder_list[:600] assert len(folder_list) != 0, "Can not find any structure" print('Found %d structures, have cost %d seconds' % (len(folder_list), time.time() - begin))
if self.multiprocessing == 0: print(f'Use multiprocessing (nodes = num_processors x num_threads = 1 x {torch.get_num_threads()})') data_list = [self.process_worker(folder) for folder in tqdm.tqdm(folder_list)] else: pool_dict = {} if self.multiprocessing < 0 else {'nodes': self.multiprocessing} # BS (2023.06.06): # The keyword "num_threads" in kernel.py can be used to set the torch threads. # The multiprocessing in the "process_worker" is in contradiction with the num_threads utilized in torch. # To avoid this conflict, I limit the number of torch threads to one, # and recover it when finishing the process_worker. torch_num_threads = torch.get_num_threads() torch.set_num_threads(1)
with Pool(**pool_dict) as pool: nodes = pool.nodes print(f'Use multiprocessing (nodes = num_processors x num_threads = {nodes} x {torch.get_num_threads()})') data_list = list(tqdm.tqdm(pool.imap(self.process_worker, folder_list), total=len(folder_list))) torch.set_num_threads(torch_num_threads) print('Finish processing %d structures, have cost %d seconds' % (len(data_list), time.time() - begin))
if self.pre_filter is not None: data_list = [d for d in data_list if self.pre_filter(d)] if self.pre_transform is not None: data_list = [self.pre_transform(d) for d in data_list]
index_to_Z, Z_to_index = self.element_statistics(data_list) spinful = data_list[0].spinful for d in data_list: assert spinful == d.spinful
data, slices = self.collate(data_list) torch.save((data, slices, dict(spinful=spinful, index_to_Z=index_to_Z, Z_to_index=Z_to_index)), self.data_file) print('Finish saving %d structures to %s, have cost %d seconds' % ( len(data_list), self.data_file, time.time() - begin))
def element_statistics(self, data_list): index_to_Z, inverse_indices = torch.unique(data_list[0].x, sorted=True, return_inverse=True) Z_to_index = torch.full((100,), -1, dtype=torch.int64) Z_to_index[index_to_Z] = torch.arange(len(index_to_Z))
for data in data_list: data.x = Z_to_index[data.x]
return index_to_Z, Z_to_index12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788[basic]graph_dir = /your/own/pathsave_dir = /your/own/pathraw_dir = /your/own/pathdataset_name = your_own_nameonly_get_graph = False;choices = ['h5', 'npz']interface = h5target = hamiltoniandisable_cuda = Falsedevice = cuda:0;-1 for cpu_count(logical=False) // torch.cuda.device_count()num_threads = -1save_to_time_folder = Truesave_csv = Falsetb_writer = Trueseed = 42multiprocessing = 0orbital = [{"6 6": [0, 0]}, {"6 6": [0, 1]}, {"6 6": [0, 2]}, {"6 6": [0, 3]}, {"6 6": [0, 4]}, {"6 6": [0, 5]}, {"6 6": [0, 6]}, {"6 6": [0, 7]}, {"6 6": [0, 8]}, {"6 6": [0, 9]}, {"6 6": [0, 10]}, {"6 6": [0, 11]}, {"6 6": [0, 12]}, {"6 6": [1, 0]}, {"6 6": [1, 1]}, {"6 6": [1, 2]}, {"6 6": [1, 3]}, {"6 6": [1, 4]}, {"6 6": [1, 5]}, {"6 6": [1, 6]}, {"6 6": [1, 7]}, {"6 6": [1, 8]}, {"6 6": [1, 9]}, {"6 6": [1, 10]}, {"6 6": [1, 11]}, {"6 6": [1, 12]}, {"6 6": [2, 0]}, {"6 6": [2, 1]}, {"6 6": [2, 2]}, {"6 6": [2, 3]}, {"6 6": [2, 4]}, {"6 6": [2, 5]}, {"6 6": [2, 6]}, {"6 6": [2, 7]}, {"6 6": [2, 8]}, {"6 6": [2, 9]}, {"6 6": [2, 10]}, {"6 6": [2, 11]}, {"6 6": [2, 12]}, {"6 6": [3, 0]}, {"6 6": [3, 1]}, {"6 6": [3, 2]}, {"6 6": [3, 3]}, {"6 6": [3, 4]}, {"6 6": [3, 5]}, {"6 6": [3, 6]}, {"6 6": [3, 7]}, {"6 6": [3, 8]}, {"6 6": [3, 9]}, {"6 6": [3, 10]}, {"6 6": [3, 11]}, {"6 6": [3, 12]}, {"6 6": [4, 0]}, {"6 6": [4, 1]}, {"6 6": [4, 2]}, {"6 6": [4, 3]}, {"6 6": [4, 4]}, {"6 6": [4, 5]}, {"6 6": [4, 6]}, {"6 6": [4, 7]}, {"6 6": [4, 8]}, {"6 6": [4, 9]}, {"6 6": [4, 10]}, {"6 6": [4, 11]}, {"6 6": [4, 12]}, {"6 6": [5, 0]}, {"6 6": [5, 1]}, {"6 6": [5, 2]}, {"6 6": [5, 3]}, {"6 6": [5, 4]}, {"6 6": [5, 5]}, {"6 6": [5, 6]}, {"6 6": [5, 7]}, {"6 6": [5, 8]}, {"6 6": [5, 9]}, {"6 6": [5, 10]}, {"6 6": [5, 11]}, {"6 6": [5, 12]}, {"6 6": [6, 0]}, {"6 6": [6, 1]}, {"6 6": [6, 2]}, {"6 6": [6, 3]}, {"6 6": [6, 4]}, {"6 6": [6, 5]}, {"6 6": [6, 6]}, {"6 6": [6, 7]}, {"6 6": [6, 8]}, {"6 6": [6, 9]}, {"6 6": [6, 10]}, {"6 6": [6, 11]}, {"6 6": [6, 12]}, {"6 6": [7, 0]}, {"6 6": [7, 1]}, {"6 6": [7, 2]}, {"6 6": [7, 3]}, {"6 6": [7, 4]}, {"6 6": [7, 5]}, {"6 6": [7, 6]}, {"6 6": [7, 7]}, {"6 6": [7, 8]}, {"6 6": [7, 9]}, {"6 6": [7, 10]}, {"6 6": [7, 11]}, {"6 6": [7, 12]}, {"6 6": [8, 0]}, {"6 6": [8, 1]}, {"6 6": [8, 2]}, {"6 6": [8, 3]}, {"6 6": [8, 4]}, {"6 6": [8, 5]}, {"6 6": [8, 6]}, {"6 6": [8, 7]}, {"6 6": [8, 8]}, {"6 6": [8, 9]}, {"6 6": [8, 10]}, {"6 6": [8, 11]}, {"6 6": [8, 12]}, {"6 6": [9, 0]}, {"6 6": [9, 1]}, {"6 6": [9, 2]}, {"6 6": [9, 3]}, {"6 6": [9, 4]}, {"6 6": [9, 5]}, {"6 6": [9, 6]}, {"6 6": [9, 7]}, {"6 6": [9, 8]}, {"6 6": [9, 9]}, {"6 6": [9, 10]}, {"6 6": [9, 11]}, {"6 6": [9, 12]}, {"6 6": [10, 0]}, {"6 6": [10, 1]}, {"6 6": [10, 2]}, {"6 6": [10, 3]}, {"6 6": [10, 4]}, {"6 6": [10, 5]}, {"6 6": [10, 6]}, {"6 6": [10, 7]}, {"6 6": [10, 8]}, {"6 6": [10, 9]}, {"6 6": [10, 10]}, {"6 6": [10, 11]}, {"6 6": [10, 12]}, {"6 6": [11, 0]}, {"6 6": [11, 1]}, {"6 6": [11, 2]}, {"6 6": [11, 3]}, {"6 6": [11, 4]}, {"6 6": [11, 5]}, {"6 6": [11, 6]}, {"6 6": [11, 7]}, {"6 6": [11, 8]}, {"6 6": [11, 9]}, {"6 6": [11, 10]}, {"6 6": [11, 11]}, {"6 6": [11, 12]}, {"6 6": [12, 0]}, {"6 6": [12, 1]}, {"6 6": [12, 2]}, {"6 6": [12, 3]}, {"6 6": [12, 4]}, {"6 6": [12, 5]}, {"6 6": [12, 6]}, {"6 6": [12, 7]}, {"6 6": [12, 8]}, {"6 6": [12, 9]}, {"6 6": [12, 10]}, {"6 6": [12, 11]}, {"6 6": [12, 12]}]O_component = Henergy_component = summationmax_element = -1statistics = Falsenormalizer = Falseboxcox = False
[graph]radius = -1.0max_num_nbr = 0create_from_DFT = Trueif_lcmp_graph = Trueseparate_onsite = Falsenew_sp = False
[train]epochs = 4000pretrained =resume =train_ratio = 0.6val_ratio = 0.2test_ratio = 0.2early_stopping_loss = 0.0early_stopping_loss_epoch = [0.000000, 500]revert_then_decay = Truerevert_threshold = 30revert_decay_epoch = [500, 2000, 3000]revert_decay_gamma = [0.4, 0.5, 0.5]clip_grad = Trueclip_grad_value = 4.2switch_sgd = Falseswitch_sgd_lr = 1e-4switch_sgd_epoch = -1
[hyperparameter]batch_size = 3dtype = float32;choices = ['sgd', 'sgdm', 'adam', 'lbfgs']optimizer = adam;initial learning ratelearning_rate = 0.001;choices = ['', 'MultiStepLR', 'ReduceLROnPlateau', 'CyclicLR']lr_scheduler =lr_milestones = []momentum = 0.9weight_decay = 0criterion = MaskMSELossretain_edge_fea = Truelambda_Eij = 0.0lambda_Ei = 0.1lambda_Etot = 0.0
[network]atom_fea_len = 64edge_fea_len = 128gauss_stop = 6;The number of angular quantum numbers that spherical harmonic functions havenum_l = 5aggr = adddistance_expansion = GaussianBasisif_exp = Trueif_MultipleLinear = Falseif_edge_update = Trueif_lcmp = Truenormalization = LayerNorm;choices = ['CGConv', 'GAT', 'PAINN']atom_update_net = CGConvtrainable_gaussians = Falsetype_affine = False1from .rmnet import RBF, cosine_cutoff, ShiftedSoftplus, _eps1The code in this folder was obtained from "https://github.com/sakuraiiiii/HermNet"123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105import math
import torchfrom torch import nn, Tensorimport numpy as np
_eps = 1e-3
r"""Tricks: Introducing the parameter `_eps` is to avoid NaN.In HVNet and HTNet, a subgraph will be extracted to calculate angles. And with all the nodes still be included in the subgraph, each hidden state in such a subgraph will contain 0 value.In `painn`, the calculation w.r.t $r / \parallel r \parallel$ will be taken.If just alternate $r / \parallel r \parallel$ with $r / (\parallel r \parallel + _eps)$, NaN will still occur in during the training.Considering the following example,$$(\frac{x}{r+_eps})^\prime = \frac{r+b-\frac{x^2}{r}}{(r+b)^2}$$where $r = \sqrt{x^2+y^2+z^2}$. It is obvious that NaN will occur.Thus the solution is change the norm $r$ as $r^\prime = \sqrt(x^2+y^2+z^2+_eps)$.Since $r$ is rotational invariant, $r^2$ is rotational invariant.Obviously, $\sqrt(r^2 + _eps)$ is rotational invariant."""class RBF(nn.Module): r"""Radial basis function. A modified version of feature engineering in `DimeNet`, which is used in `PAINN`.
Parameters ---------- rc : float Cutoff radius l : int Parameter in feature engineering in DimeNet """ def __init__(self, rc: float, l: int): super(RBF, self).__init__() self.rc = rc self.l = l
def forward(self, x: Tensor): ls = torch.arange(1, self.l + 1).float().to(x.device) norm = torch.sqrt((x ** 2).sum(dim=-1) + _eps).unsqueeze(-1) return torch.sin(math.pi / self.rc * norm@ls.unsqueeze(0)) / norm
class cosine_cutoff(nn.Module): r"""Cutoff function in https://aip.scitation.org/doi/pdf/10.1063/1.3553717.
Parameters ---------- rc : float Cutoff radius """ def __init__(self, rc: float): super(cosine_cutoff, self).__init__() self.rc = rc
def forward(self, x: Tensor): norm = torch.norm(x, dim=-1, keepdim=True) + _eps return 0.5 * (torch.cos(math.pi * norm / self.rc) + 1)
class ShiftedSoftplus(nn.Module): r"""
Description ----------- Applies the element-wise function:
.. math:: \text{SSP}(x) = \frac{1}{\beta} * \log(1 + \exp(\beta * x)) - \log(\text{shift})
Attributes ---------- beta : int :math:`\beta` value for the mathematical formulation. Default to 1. shift : int :math:`\text{shift}` value for the mathematical formulation. Default to 2. """ def __init__(self, beta=1, shift=2, threshold=20): super(ShiftedSoftplus, self).__init__()
self.shift = shift self.softplus = nn.Softplus(beta=beta, threshold=threshold)
def forward(self, inputs): """
Description ----------- Applies the activation function.
Parameters ---------- inputs : float32 tensor of shape (N, *) * denotes any number of additional dimensions.
Returns ------- float32 tensor of shape (N, *) Result of applying the activation function to the input. """ return self.softplus(inputs) - np.log(float(self.shift))12from .graph_norm import GraphNormfrom .diff_group_norm import DiffGroupNorm123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109import torchfrom torch import Tensorfrom torch.nn import Linear, BatchNorm1d
class DiffGroupNorm(torch.nn.Module): r"""The differentiable group normalization layer from the `"Towards Deeper Graph Neural Networks with Differentiable Group Normalization" <https://arxiv.org/abs/2006.06972>`_ paper, which normalizes node features group-wise via a learnable soft cluster assignment
.. math::
\mathbf{S} = \text{softmax} (\mathbf{X} \mathbf{W})
where :math:`\mathbf{W} \in \mathbb{R}^{F \times G}` denotes a trainable weight matrix mapping each node into one of :math:`G` clusters. Normalization is then performed group-wise via:
.. math::
\mathbf{X}^{\prime} = \mathbf{X} + \lambda \sum_{i = 1}^G \text{BatchNorm}(\mathbf{S}[:, i] \odot \mathbf{X})
Args: in_channels (int): Size of each input sample :math:`F`. groups (int): The number of groups :math:`G`. lamda (float, optional): The balancing factor :math:`\lambda` between input embeddings and normalized embeddings. (default: :obj:`0.01`) eps (float, optional): A value added to the denominator for numerical stability. (default: :obj:`1e-5`) momentum (float, optional): The value used for the running mean and running variance computation. (default: :obj:`0.1`) affine (bool, optional): If set to :obj:`True`, this module has learnable affine parameters :math:`\gamma` and :math:`\beta`. (default: :obj:`True`) track_running_stats (bool, optional): If set to :obj:`True`, this module tracks the running mean and variance, and when set to :obj:`False`, this module does not track such statistics and always uses batch statistics in both training and eval modes. (default: :obj:`True`) """ def __init__(self, in_channels, groups, lamda=0.01, eps=1e-5, momentum=0.1, affine=True, track_running_stats=True): super(DiffGroupNorm, self).__init__()
self.in_channels = in_channels self.groups = groups self.lamda = lamda
self.lin = Linear(in_channels, groups, bias=False) self.norm = BatchNorm1d(groups * in_channels, eps, momentum, affine, track_running_stats)
self.reset_parameters()
def reset_parameters(self): self.lin.reset_parameters() self.norm.reset_parameters()
def forward(self, x: Tensor) -> Tensor: """""" F, G = self.in_channels, self.groups
s = self.lin(x).softmax(dim=-1) # [N, G] out = s.unsqueeze(-1) * x.unsqueeze(-2) # [N, G, F] out = self.norm(out.view(-1, G * F)).view(-1, G, F).sum(-2) # [N, F]
return x + self.lamda * out
@staticmethod def group_distance_ratio(x: Tensor, y: Tensor, eps: float = 1e-5) -> float: r"""Measures the ratio of inter-group distance over intra-group distance
.. math:: R_{\text{Group}} = \frac{\frac{1}{(C-1)^2} \sum_{i!=j} \frac{1}{|\mathbf{X}_i||\mathbf{X}_j|} \sum_{\mathbf{x}_{iv} \in \mathbf{X}_i } \sum_{\mathbf{x}_{jv^{\prime}} \in \mathbf{X}_j} {\| \mathbf{x}_{iv} - \mathbf{x}_{jv^{\prime}} \|}_2 }{ \frac{1}{C} \sum_{i} \frac{1}{{|\mathbf{X}_i|}^2} \sum_{\mathbf{x}_{iv}, \mathbf{x}_{iv^{\prime}} \in \mathbf{X}_i } {\| \mathbf{x}_{iv} - \mathbf{x}_{iv^{\prime}} \|}_2 }
where :math:`\mathbf{X}_i` denotes the set of all nodes that belong to class :math:`i`, and :math:`C` denotes the total number of classes in :obj:`y`. """ num_classes = int(y.max()) + 1
numerator = 0. for i in range(num_classes): mask = y == i dist = torch.cdist(x[mask].unsqueeze(0), x[~mask].unsqueeze(0)) numerator += (1 / dist.numel()) * float(dist.sum()) numerator *= 1 / (num_classes - 1)**2
denominator = 0. for i in range(num_classes): mask = y == i dist = torch.cdist(x[mask].unsqueeze(0), x[mask].unsqueeze(0)) denominator += (1 / dist.numel()) * float(dist.sum()) denominator *= 1 / num_classes
return numerator / (denominator + eps)
def __repr__(self): return '{}({}, groups={})'.format(self.__class__.__name__, self.in_channels, self.groups)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960from typing import Optional
import torchfrom torch import Tensorfrom torch_scatter import scatter_mean
from torch_geometric.nn.inits import zeros, ones
class GraphNorm(torch.nn.Module): r"""Applies graph normalization over individual graphs as described in the `"GraphNorm: A Principled Approach to Accelerating Graph Neural Network Training" <https://arxiv.org/abs/2009.03294>`_ paper
.. math:: \mathbf{x}^{\prime}_i = \frac{\mathbf{x} - \alpha \odot \textrm{E}[\mathbf{x}]} {\sqrt{\textrm{Var}[\mathbf{x} - \alpha \odot \textrm{E}[\mathbf{x}]] + \epsilon}} \odot \gamma + \beta
where :math:`\alpha` denotes parameters that learn how much information to keep in the mean.
Args: in_channels (int): Size of each input sample. eps (float, optional): A value added to the denominator for numerical stability. (default: :obj:`1e-5`) """ def __init__(self, in_channels: int, eps: float = 1e-5): super(GraphNorm, self).__init__()
self.in_channels = in_channels self.eps = eps
self.weight = torch.nn.Parameter(torch.Tensor(in_channels)) self.bias = torch.nn.Parameter(torch.Tensor(in_channels)) self.mean_scale = torch.nn.Parameter(torch.Tensor(in_channels))
self.reset_parameters()
def reset_parameters(self): ones(self.weight) zeros(self.bias) ones(self.mean_scale)
def forward(self, x: Tensor, batch: Optional[Tensor] = None) -> Tensor: """""" if batch is None: batch = x.new_zeros(x.size(0), dtype=torch.long)
batch_size = int(batch.max()) + 1
mean = scatter_mean(x, batch, dim=0, dim_size=batch_size)[batch] out = x - mean * self.mean_scale var = scatter_mean(out.pow(2), batch, dim=0, dim_size=batch_size) std = (var + self.eps).sqrt()[batch] return self.weight * out / std + self.bias
def __repr__(self): return f'{self.__class__.__name__}({self.in_channels})'12345678910111213141516171819202122The code in this folder was obtained from "https://github.com/rusty1s/pytorch_geometric", which has the following license:
Copyright (c) 2020 Matthias Fey <matthias.fey@tu-dortmund.de>
Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included inall copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS INTHE SOFTWARE.1from .lattice import find_neighbors, _one_to_three, _compute_cube_index, _three_to_one1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071import itertoolsimport numpy as np
# The following internal methods are used in the get_points_in_sphere method.def _compute_cube_index(coords: np.ndarray, global_min: float, radius: float ) -> np.ndarray: """ Compute the cube index from coordinates Args: coords: (nx3 array) atom coordinates global_min: (float) lower boundary of coordinates radius: (float) cutoff radius
Returns: (nx3 array) int indices
""" return np.array(np.floor((coords - global_min) / radius), dtype=int)
def _three_to_one(label3d: np.ndarray, ny: int, nz: int) -> np.ndarray: """ The reverse of _one_to_three """ return np.array(label3d[:, 0] * ny * nz + label3d[:, 1] * nz + label3d[:, 2]).reshape((-1, 1))
def _one_to_three(label1d: np.ndarray, ny: int, nz: int) -> np.ndarray: """ Convert a 1D index array to 3D index array
Args: label1d: (array) 1D index array ny: (int) number of cells in y direction nz: (int) number of cells in z direction
Returns: (nx3) int array of index
""" last = np.mod(label1d, nz) second = np.mod((label1d - last) / nz, ny) first = (label1d - last - second * nz) / (ny * nz) return np.concatenate([first, second, last], axis=1)
def find_neighbors(label: np.ndarray, nx: int, ny: int, nz: int): """ Given a cube index, find the neighbor cube indices
Args: label: (array) (n,) or (n x 3) indice array nx: (int) number of cells in y direction ny: (int) number of cells in y direction nz: (int) number of cells in z direction
Returns: neighbor cell indices
"""
array = [[-1, 0, 1]] * 3 neighbor_vectors = np.array(list(itertools.product(*array)), dtype=int) if np.shape(label)[1] == 1: label3d = _one_to_three(label, ny, nz) else: label3d = label all_labels = label3d[:, None, :] - neighbor_vectors[None, :, :] filtered_labels = [] # filter out out-of-bound labels i.e., label < 0 for labels in all_labels: ind = (labels[:, 0] < nx) * (labels[:, 1] < ny) * (labels[:, 2] < nz) * np.all(labels > -1e-5, axis=1) filtered_labels.append(labels[ind]) return filtered_labels12345678910111213141516171819202122The code in this folder was obtained from "https://github.com/materialsproject/pymatgen", which has the following license:
The MIT License (MIT)Copyright (c) 2011-2012 MIT & The Regents of the University of California, through Lawrence Berkeley National Laboratory
Permission is hereby granted, free of charge, to any person obtaining a copy ofthis software and associated documentation files (the "Software"), to deal inthe Software without restriction, including without limitation the rights touse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies ofthe Software, and to permit persons to whom the Software is furnished to do so,subject to the following conditions:
The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESSFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS ORCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHERIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR INCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.1from .acsf import GaussianBasis1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950import torchfrom torch import nn
def gaussian_smearing(distances, offset, widths, centered=False): if not centered: # compute width of Gaussian functions (using an overlap of 1 STDDEV) coeff = -0.5 / torch.pow(widths, 2) # Use advanced indexing to compute the individual components diff = distances[..., None] - offset else: # if Gaussian functions are centered, use offsets to compute widths coeff = -0.5 / torch.pow(offset, 2) # if Gaussian functions are centered, no offset is subtracted diff = distances[..., None] # compute smear distance values gauss = torch.exp(coeff * torch.pow(diff, 2)) return gauss
class GaussianBasis(nn.Module): def __init__( self, start=0.0, stop=5.0, n_gaussians=50, centered=False, trainable=False ): super(GaussianBasis, self).__init__() # compute offset and width of Gaussian functions offset = torch.linspace(start, stop, n_gaussians) widths = torch.FloatTensor((offset[1] - offset[0]) * torch.ones_like(offset)) if trainable: self.width = nn.Parameter(widths) self.offsets = nn.Parameter(offset) else: self.register_buffer("width", widths) self.register_buffer("offsets", offset) self.centered = centered
def forward(self, distances): """Compute smeared-gaussian distance values.
Args: distances (torch.Tensor): interatomic distance values of (N_b x N_at x N_nbh) shape.
Returns: torch.Tensor: layer output of (N_b x N_at x N_nbh x N_g) shape.
""" return gaussian_smearing( distances, self.offsets, self.width, centered=self.centered )1234567891011121314151617181920212223242526272829303132333435The code in this folder was obtained from "https://github.com/atomistic-machine-learning/schnetpack", which has the following license:
COPYRIGHT
Copyright (c) 2018 Kristof Schütt, Michael Gastegger, Pan Kessel, Kim Nicoli
All other contributions:Copyright (c) 2018, the respective contributors.All rights reserved.
Each contributor holds copyright over their respective contributions.The project versioning (Git) records all such contribution source information.
LICENSE
The MIT License
Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.1from .representations import SphericalHarmonics.gitattributes+1
2_training/forces/_phonopy_freqs.jsonAdded+1
2_training/forces/diamond_ase_ref.nequip.pt2Added+3
2_training/forces/phonon_comparison.pngAdded

Large File Pointer Details
- SHA256: fcf45a338a03b006c6d895f7bd9ea3a666b8de3b327dd74930b819689b08816d
- Pointer size: 130 Bytes
- Size of remote file: 32.9 kB
2_training/forces/train_force.logAdded+38
2_training/hamiltonian/infer_sc/dataset/00/overlaps.h5Added+3
2_training/hamiltonian/infer_uc/dataset/00/element.datAdded+2
2_training/hamiltonian/infer_uc/dataset/00/graph.pklAdded+3
2_training/hamiltonian/infer_uc/dataset/00/hamiltonians.h5Added+3
2_training/hamiltonian/infer_uc/dataset/00/hamiltonians_pred.h5Added+3
2_training/hamiltonian/infer_uc/dataset/00/info.jsonAdded+1
2_training/hamiltonian/infer_uc/dataset/00/lat.datAdded+3
2_training/hamiltonian/infer_uc/dataset/00/orbital_types.datAdded+2
2_training/hamiltonian/infer_uc/dataset/00/overlaps.h5Added+3
2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/config.iniAdded+82
2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/result.txtAdded+86
2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/__init__.pyAdded+10
2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/__pycache__/__init__.cpython-312.pycAdded
2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/__pycache__/data.cpython-312.pycAdded
2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/__pycache__/graph.cpython-312.pycAdded
2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/__pycache__/kernel.cpython-312.pycAdded
2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/__pycache__/model.cpython-312.pycAdded
2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/__pycache__/rotate.cpython-312.pycAdded
2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/__pycache__/utils.cpython-312.pycAdded
2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/data.pyAdded+217
2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/default.iniAdded+88
2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_HermNet/__init__.pyAdded+1
2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_HermNet/__pycache__/__init__.cpython-312.pycAdded
2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_HermNet/__pycache__/rmnet.cpython-312.pycAdded
2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_HermNet/license.txtAdded+1
2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_HermNet/rmnet.pyAdded+105
2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/__init__.pyAdded+2
2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/__pycache__/__init__.cpython-312.pycAdded
2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/__pycache__/diff_group_norm.cpython-312.pycAdded
2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/__pycache__/graph_norm.cpython-312.pycAdded
2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/diff_group_norm.pyAdded+109
2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/graph_norm.pyAdded+60
2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/license.txtAdded+22
2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_pymatgen/__init__.pyAdded+1
2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_pymatgen/__pycache__/__init__.cpython-312.pycAdded
2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_pymatgen/__pycache__/lattice.cpython-312.pycAdded
2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_pymatgen/lattice.pyAdded+71
2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_pymatgen/license.txtAdded+22
2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_schnetpack/__init__.pyAdded+1
2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_schnetpack/__pycache__/__init__.cpython-312.pycAdded
2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_schnetpack/__pycache__/acsf.cpython-312.pycAdded
2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_schnetpack/acsf.pyAdded+50
2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_schnetpack/license.txtAdded+35
2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_se3_transformer/__init__.pyAdded+1
2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_se3_transformer/__pycache__/__init__.cpython-312.pycAdded