megnet.models.megnet module¶
Implements megnet models.
-
class
MEGNetModel
(nfeat_edge: int = None, nfeat_global: int = None, nfeat_node: int = None, nblocks: int = 3, lr: float = 0.001, n1: int = 64, n2: int = 32, n3: int = 16, nvocal: int = 95, embedding_dim: int = 16, nbvocal: int = None, bond_embedding_dim: int = None, ngvocal: int = None, global_embedding_dim: int = None, npass: int = 3, ntarget: int = 1, act: Callable = <function softplus2>, is_classification: bool = False, loss: str = 'mse', metrics: List[str] = None, l2_coef: float = None, dropout: float = None, graph_converter: megnet.data.graph.StructureGraph = None, target_scaler: megnet.utils.preprocessing.Scaler = <megnet.utils.preprocessing.DummyScaler object>, optimizer_kwargs: Dict = None, dropout_on_predict: bool = False)[source]¶ Bases:
megnet.models.base.GraphModel
Construct a graph network model with or without explicit atom features if n_feature is specified then a general graph model is assumed, otherwise a crystal graph model with z number as atom feature is assumed.
- Parameters
nfeat_edge – (int) number of bond features
nfeat_global – (int) number of state features
nfeat_node – (int) number of atom features
nblocks – (int) number of MEGNetLayer blocks
lr – (float) learning rate
n1 – (int) number of hidden units in layer 1 in MEGNetLayer
n2 – (int) number of hidden units in layer 2 in MEGNetLayer
n3 – (int) number of hidden units in layer 3 in MEGNetLayer
nvocal – (int) number of total element
embedding_dim – (int) number of embedding dimension
nbvocal – (int) number of bond types if bond attributes are types
bond_embedding_dim – (int) number of bond embedding dimension
ngvocal – (int) number of global types if global attributes are types
global_embedding_dim – (int) number of global embedding dimension
npass – (int) number of recurrent steps in Set2Set layer
ntarget – (int) number of output targets
act – (object) activation function
l2_coef – (float or None) l2 regularization parameter
is_classification – (bool) whether it is a classification task
loss – (object or str) loss function
metrics – (list or dict) List or dictionary of Keras metrics to be evaluated by the model during training and testing
dropout – (float) dropout rate
graph_converter – (object) object that exposes a “convert” method for structure to graph conversion
target_scaler – (object) object that exposes a “transform” and “inverse_transform” methods for transforming the target values
optimizer_kwargs (dict) – extra keywords for optimizer, for example clipnorm and clipvalue
-
classmethod
from_mvl_models
(name: str) → megnet.models.megnet.MEGNetModel[source]¶
-
classmethod
from_url
(url: str) → megnet.models.megnet.MEGNetModel[source]¶ Download and load a model from a URL. E.g. https://github.com/materialsvirtuallab/megnet/blob/master/mvl_models/mp-2019.4.1/formation_energy.hdf5
- Parameters
url – (str) url link of the model
- Returns
GraphModel
-
make_megnet_model
(nfeat_edge: int = None, nfeat_global: int = None, nfeat_node: int = None, nblocks: int = 3, n1: int = 64, n2: int = 32, n3: int = 16, nvocal: int = 95, embedding_dim: int = 16, nbvocal: int = None, bond_embedding_dim: int = None, ngvocal: int = None, global_embedding_dim: int = None, npass: int = 3, ntarget: int = 1, act: Callable = <function softplus2>, is_classification: bool = False, l2_coef: float = None, dropout: float = None, dropout_on_predict: bool = False) → tensorflow.python.keras.engine.training.Model[source]¶ Make a MEGNet Model
- Parameters
nfeat_edge – (int) number of bond features
nfeat_global – (int) number of state features
nfeat_node – (int) number of atom features
nblocks – (int) number of MEGNetLayer blocks
n1 – (int) number of hidden units in layer 1 in MEGNetLayer
n2 – (int) number of hidden units in layer 2 in MEGNetLayer
n3 – (int) number of hidden units in layer 3 in MEGNetLayer
nvocal – (int) number of total element
embedding_dim – (int) number of embedding dimension
nbvocal – (int) number of bond types if bond attributes are types
bond_embedding_dim – (int) number of bond embedding dimension
ngvocal – (int) number of global types if global attributes are types
global_embedding_dim – (int) number of global embedding dimension
npass – (int) number of recurrent steps in Set2Set layer
ntarget – (int) number of output targets
act – (object) activation function
l2_coef – (float or None) l2 regularization parameter
is_classification – (bool) whether it is a classification task
dropout – (float) dropout rate
dropout_on_predict (bool) – Whether to use dropout during prediction and training
- Returns
(Model) Keras model, ready to run