xnn.gnn.models.megnet_foundation#

The pretrained MEGNet models of MatGL, converted weight for weight.

MatGL (BSD-3-Clause) publishes two MEGNet property models: the formation energy per atom of the Materials Project 2018.6.1 crystals (eV/atom) and the multi-fidelity band gap of the 2019.4.1 crystals (eV, fidelities PBE, GLLB-SC, HSE and SCAN). Each is a directory of model.json (the architecture), model.pt (the target standardization) and state.pt (the weights). The architecture is xnn’s MEGNet with the same layer layout; the standardization becomes property_scale and property_shift.

The formation energy model was trained with the bond direction reversed: its bond updates average at the atom MatGL now lists second. from_foundation swaps the two atom blocks of every bond update’s first layer to match, which restores its published accuracy (current MatGL does not). The band gap model is converted as MatGL runs it.

MEGNet.from_foundation("megnet-mp-2019.4.1-bandgap-mfi") downloads a pinned revision into the model cache and converts it; a local directory loads through the model hub’s "matgl" format (xnn.common.models.from_pretrained(path)).

Module Attributes

FOUNDATION_MODELS

name -> (folder, pinned revision, MD5 of every file, state names, whether the weights were trained with the bond direction reversed).

Functions

convert_directory(path[, dtype, state_names])

Convert a MatGL MEGNet directory into xnn's MEGNet.

from_foundation([name, dtype, cache_dir, quiet])

Download (once) and convert a registered MatGL MEGNet model.

swap_bond_atoms(model)

Swap the receiving and sending atom blocks of the first layer of every bond update, in place.