{"id":43500958,"url":"https://github.com/aimat-lab/nnsformd","last_synced_at":"2026-02-03T11:23:25.575Z","repository":{"id":45737446,"uuid":"291693769","full_name":"aimat-lab/NNsForMD","owner":"aimat-lab","description":"Neural network class for molecular dynamics to predict potential energy, forces and non-adiabatic couplings.","archived":false,"fork":false,"pushed_at":"2022-11-10T13:04:49.000Z","size":2232,"stargazers_count":10,"open_issues_count":0,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-09T21:48:10.253Z","etag":null,"topics":["ab-initio-simulations","excited-states","machine-learning","molecular-dynamics","neural-network","potentials"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aimat-lab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-31T11:14:18.000Z","updated_at":"2023-12-13T16:43:47.000Z","dependencies_parsed_at":"2023-01-21T21:19:23.680Z","dependency_job_id":null,"html_url":"https://github.com/aimat-lab/NNsForMD","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/aimat-lab/NNsForMD","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aimat-lab%2FNNsForMD","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aimat-lab%2FNNsForMD/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aimat-lab%2FNNsForMD/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aimat-lab%2FNNsForMD/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aimat-lab","download_url":"https://codeload.github.com/aimat-lab/NNsForMD/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aimat-lab%2FNNsForMD/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29044110,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-03T10:09:22.136Z","status":"ssl_error","status_checked_at":"2026-02-03T10:09:16.814Z","response_time":96,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ab-initio-simulations","excited-states","machine-learning","molecular-dynamics","neural-network","potentials"],"created_at":"2026-02-03T11:23:24.327Z","updated_at":"2026-02-03T11:23:25.549Z","avatar_url":"https://github.com/aimat-lab.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Documentation Status](https://readthedocs.org/projects/pynnsmd/badge/?version=latest)](https://pynnsmd.readthedocs.io/en/latest/?badge=latest)\n![PyPI](https://img.shields.io/pypi/v/pyNNsMD)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/pyNNsMD)\n![GitHub release (latest by date)](https://img.shields.io/github/v/release/aimat-lab/NNsForMD)\n\n# NNsForMD\n\nNeural network class for molecular dynamics to predict potential energy, gradients and non-adiabatic couplings (NACs).\n\n# Table of Contents\n* [General](#general)\n* [Installation](#installation)\n* [Documentation](#documentation)\n* [Usage](#usage)\n* [Examples](#examples)\n* [Citing](#citing)\n* [References](#references)\n\n\u003ca name=\"general\"\u003e\u003c/a\u003e\n# General\nThis repo is currently under construction. The original version used as the PyRAI2MD interface is v1.0.0.\n\n\n\n\u003ca name=\"installation\"\u003e\u003c/a\u003e\n# Installation\n\nClone repository https://github.com/aimat-lab/NNsForMD and install for example with editable mode:\n\n```bash\npip install -e ./pyNNsMD\n```\nor latest release via Python Package Index.\n\n```bash\npip install pyNNsMD\n```\n\n\u003ca name=\"documentation\"\u003e\u003c/a\u003e\n# Documentation\n\nAuto-documentation generated at https://pynnsmd.readthedocs.io/en/latest/index.html\n\n\u003ca name=\"usage\"\u003e\u003c/a\u003e\n# Usage\n\n#### Ensemble\nThe main class ``pyNNsMD.NNsMD.NeuralNetEnsemble`` holds a list of keras models and custom scaler classes to transform or standardize input/output.\nConstruction of ``NeuralNetEnsemble`` requires a filepath and the number of model instances to keep.\n\n```python\nfrom pyNNsMD.NNsMD import NeuralNetEnsemble\nnn = NeuralNetEnsemble(\"TestEnergy/\", 2)\n```\n\nAdding the models and scaler classes to ``NeuralNetEnsemble`` via `create`. \nCustom classes can be added to the modules in ``pyNNsMD.models`` and ``pyNNsMD.scalers``, \nbut which must implement proper config and weight handling. \nNote that data format between model and scaler must be compatible.\nInstead of class instances a deserialization via keras config-dictionaries is supported for `create()`.\n\n```python\nfrom pyNNsMD.models.mlp_e import EnergyModel\nfrom pyNNsMD.scaler.energy import EnergyStandardScaler\n\nnn.create(models=[EnergyModel(atoms=12, states=2), EnergyModel(atoms=12, states=2)],\n          scalers=[EnergyStandardScaler(), EnergyStandardScaler()])\n```\n\nThe models and scaler must be saved to disk to prepare for training, which includes config and weights.\n\n```python\nnn.save()\n```\n\n#### Data\n\nThe data is stored to the directory specified in ``NeuralNetEnsemble``.\nData format passed to ``NeuralNetEnsemble.data()`` must be nested python-only lists.\nThe geometries are stored as `.xyz` and everything else as `.json`. \nNote that the training scripts must be compatible with the data format.\n\n```python\natoms = [[\"C\", \"C\"]]\ngeos = [[[0.147, 0.024, -0.680], [-0.165, -0.037, 0.652]]]\nenergy = [[-20386.37, -20383.93]]\n\nnn.data(atoms=atoms, geometries=geos, energies=energy)\n# nn.data_path(\"data_dir/\") if data can't be saved in working directory.\n```\n#### Training\n\nFor training the train and test indices must also be saved to file for each model directory.\nThis can be achieved via ``train_test_split()``, \nor by directly passing an index-list for each model with ``train_test_indices()``.\nNote that the different models are sought to be trained on different splits.\n\n```python\nnn.train_test_split(dataset_size=1, n_splits=1, shuffle=True) # Usually n_splits=5 or 10\n# nn.train_test_indices(train=[np.array([0]), np.array([0])], test=[np.array([0]), np.array([0])])\n```\n\nThe hyperparameter for training are passed as `.json` to each model folder. \nSee ``pyNNsMD.hypers`` modules for example hyperparameter.\n\n```python\nnn.training([{\n    'initialize_weights': True, 'epo': 1000, 'batch_size': 64, 'epostep': 10, \n    'learning_rate': 1e-3, \"callbacks\": [], 'unit_energy': \"eV\", 'unit_gradient': \"eV/A\"\n}]*2, fit_mode=\"training\")\n```\n\n#### Fitting\n\nWith `fit()` a training script is run for each model from the model's directory. \nThe training script should be stored in ``pyNNsMD.training``. \nNote that the training script must be compatible with model and data. \nThe training script must provide command line arguments 'index', 'filepath', 'gpus' and 'mode'.\nThe training can be distributed on multiple or a single gpu (for small networks).\n\n```python\nfit_error = nn.fit([\"training_mlp_e\"]*2, fit_mode=\"training\", \n                   gpu_dist=[0, 0], proc_async=True)\nprint(fit_error)\n```\n\n#### Loading\n\nAfter fitting the model can be recreated from config and the weights loaded from file with ``load()``.\n\n```python\nnn.load()\n```\n\n#### Prediction\n\nThe model's prediction can be obtained from the corresponding input data via `predict()` and ``call()``.\nThe both input and output is rescaled by the scaler to match the model standardized input and output.\nFurthermore, the subclassed model should implement ``call_to_tensor_input`` and ``call_to_numpy_output`` or optionally\n`predict_to_tensor_input` and `predict_to_numpy_output`, \nif the model requires a specific tensor input as in `call()` and the scaler class usually works on numpy data. \n\n```python\ntest = nn.predict(geos)\n# test_batch = nn.call(geos[:32])  # Faster than predict.\n```\n\n\u003ca name=\"examples\"\u003e\u003c/a\u003e\n# Examples\n\nA set of examples can be found in [examples](examples), that demonstrate usage and typical tasks for projects.\n\n\u003ca name=\"citing\"\u003e\u003c/a\u003e\n# Citing\n\nIf you want to cite this repository or the PyRAI2MD code, please refer to our publication at:\n```\n@Article{JingbaiLi2021,\n    author =\"Li, Jingbai and Reiser, Patrick and Boswell, Benjamin R. and Eberhard, André and Burns, Noah Z. and Friederich, Pascal and Lopez, Steven A.\",\n    title  =\"Automatic discovery of photoisomerization mechanisms with nanosecond machine learning photodynamics simulations\",\n    journal  =\"Chem. Sci.\",\n    year  =\"2021\",\n    pages  =\"-\",\n    publisher  =\"The Royal Society of Chemistry\",\n    doi  =\"10.1039/D0SC05610C\",\n    url  =\"http://dx.doi.org/10.1039/D0SC05610C\"\n}\n```\n\n\u003ca name=\"references\"\u003e\u003c/a\u003e\n# References\n\n* https://onlinelibrary.wiley.com/doi/full/10.1002/qua.24890\n* https://pubs.acs.org/doi/abs/10.1021/acs.chemrev.0c00749","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faimat-lab%2Fnnsformd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faimat-lab%2Fnnsformd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faimat-lab%2Fnnsformd/lists"}