Package: faenet
💻  Code•Docs  📑FAENet: Frame Averaging Equivariant GNN for Materials modelingThis repository contains an implementation of the paperFAENet: Frame Averaging Equivariant GNN for Materials modeling, accepted at ICML 2023. More precisely, you will find:FrameAveraging: the transform that projects your pytorch-geometric data into a canonical space of all euclidean transformations, as defined in the paper.FAENet: a GNN architecture for material modeling.model_forward: a high-level forward function that computes appropriate equivariant model predictions for the Frame Averaging method, i.e. handling the different frames and mapping to equivariant predictions.Also:https://github.com/vict0rsch/faenetInstallationpip install faenet⚠️ The above installation requiresPython >= 3.8,torch > 1.11,torch_geometric > 2.1to the best of our knowledge. Bothmendeleevandpandaspackage are also required to derive physics-aware atom embeddings in FAENet.Getting startedFrame Averaging TransformFrameAveragingis a Transform method applicable to pytorch-geometricDataobject, which shall be used in theget_item()function of yourDatasetclass. This method derives a new canonical position for the atomic graph, identical for all euclidean symmetries, and stores it under the data attributefa_pos. You can choose among several options for the frame averaging, ranging fromFull FAtoStochastic FA(in 2D or 3D) including traditional data augmentationDAwith rotated samples. See the fulldocfor more details. Note that, although this transform is specific to pytorch-geometric data objects, it can be easily extended to new settings since the core functionsframe_averaging_2D()andframe_averaging_3D()generalise to other data format.importtorchfromfaenet.transformsimportFrameAveragingframe_averaging="3D"# symmetry preservation method used: {"3D", "2D", "DA", ""}:fa_method="stochastic"# the frame averaging method: {"det", "all", "se3-stochastic", "se3-det", "se3-all", ""}:transform=FrameAveraging(frame_averaging,fa_method)transform(data)# transform the PyG graph dataModel forward for Frame Averagingmodel_forward()aggregates the predictions of a chosen ML model (e.g FAENet) when Frame Averaging is applied, as stipulated by the Equation (1) of the paper. INded, applying the model on canonical positions (fa_pos) directly would not yield equivariant predictions. This method must be applied at training and inference time to compute all model predictions. It requiresbatchto have pos, batch and frame averaging attributes (seedocu).fromfaenet.fa_forwardimportmodel_forwardpreds=model_forward(batch=batch,# batch from, dataloadermodel=model,# FAENet(**kwargs)frame_averaging="3D",# ["2D", "3D", "DA", ""]mode="train",# for trainingcrystal_task=True,# for crystals, with pbc conditions)FAENet GNNImplementation of the FAENet GNN model, compatible with any dataset or transform. In short, FAENet is a very simple, scalable and expressive model. Since does not explicitly preserve data symmetries, it has the ability to process directly and unrestrictedly atom relative positions, which is very efficient and powerful. Although it was specifically designed to be applied with Frame Averaging above, to preserve symmetries without any design restrictions, note that it can also be applied without. When applied with Frame Averaging, we need to use themodel_forward()function above to compute model predictions,model(data)is not enough. Note that the training procedure is not given here, you should refer to the originalgithub repository. Check thedocumentationto see all input parameters.Note that the model assumes input data (e.g.batchbelow) to have certain attributes, like atomic_numbers, batch, pos or edge_index. If your data does not have these attributes, you can apply custom pre-processing functions, takingpbc_preprocessorbase_preprocessinutils.pyas inspiration. You simply need to pass them as argument to FAENet (preprocess).fromfaenet.modelimportFAENetpreds=FAENet(**kwargs)model(batch)EvalTheeval_model_symmetries()function helps you evaluate the equivariant, invariant and other properties of a model, as we did in the paper.Note: you can predict any atom-level or graph-level property, although the code explicitly refers to energy and forces.TestsThe/testsfolder contains several useful unit-tests. Feel free to have a look at them to explore how the model can be used. For more advanced examples, please refer to the fullrepositoryused in our ICML paper to make predictions on OC20 IS2RE, S2EF, QM9 and QM7-X dataset.This requirespoetry. Make sure to havetorchandtorch_geometricinstalled in your environment before you can run the tests. Unfortunately because of CUDA/torch compatibilities, neithertorchnortorch_geometricare part of the explicit dependencies and must be installed independently.gitclonegit@github.com:vict0rsch/faenet.git
poetryinstall--withdev
pytest--cov=faenet--cov-reportterm-missingTesting on Macs you may encounter aLibrary Not Loaded ErrorContactAuthors: Alexandre Duval (alexandre.duval@mila.quebec) and Victor Schmidt (schmidtv@mila.quebec). We welcome your questions and feedback via email or GitHub Issues.