megnet.layers.graph.megnet module¶
Megnet graph layer implementation
- class MEGNetLayer(*args, **kwargs)[source]¶
Bases:
megnet.layers.graph.base.GraphNetworkLayer
The MEGNet graph implementation as described in the paper
Chen, Chi; Ye, Weike Ye; Zuo, Yunxing; Zheng, Chen; Ong, Shyue Ping. Graph Networks as a Universal Machine Learning Framework for Molecules and Crystals, 2018, arXiv preprint. [arXiv:1812.05055](https://arxiv.org/abs/1812.05055) .. method:: call(inputs, mask=None)
the logic of the layer, returns the final graph
- compute_output_shape(input_shape)[source]¶
compute static output shapes, returns list of tuple shapes
- phi_v(b_e_p, inputs)[source]¶
update the atom attributes by the results from previous step b_e_p and all the inputs returns v_p.
- Parameters
units_v (list of integers) – the hidden layer sizes for node update neural network
units_e (list of integers) – the hidden layer sizes for edge update neural network
units_u (list of integers) – the hidden layer sizes for state update neural network
pool_method (str) – ‘mean’ or ‘sum’, determines how information is gathered to nodes from neighboring edges
activation (str) – Default: None. The activation function used for each sub-neural network. Examples include ‘relu’, ‘softmax’, ‘tanh’, ‘sigmoid’ and etc.
use_bias (bool) – Default: True. Whether to use the bias term in the neural network.
kernel_initializer (str) – Default: ‘glorot_uniform’. Initialization function for the layer kernel weights,
bias_initializer (str) – Default: ‘zeros’
activity_regularizer (str) – Default: None. The regularization function for the output
kernel_constraint (str) – Default: None. Keras constraint for kernel values
bias_constraint (str) – Default: None .Keras constraint for bias values
- build(input_shapes)[source]¶
Build the weights for the layer :param input_shapes: the shapes of all input tensors :type input_shapes: sequence of tuple
- compute_output_shape(input_shape)[source]¶
Compute output shapes from input shapes :param input_shape: input shapes :type input_shape: sequence of tuple
Returns: sequence of tuples output shapes
- get_config()[source]¶
Part of keras layer interface, where the signature is converted into a dict
- Returns
configurational dictionary
- phi_e(inputs)[source]¶
Edge update function :param inputs: :type inputs: tuple of tensor
- Returns
output tensor
- phi_u(b_e_p, b_v_p, inputs)[source]¶
- Parameters
b_e_p (tf.Tensor) – edge/bond to global aggregated tensor
b_v_p (tf.Tensor) – node/atom to global aggregated tensor
inputs (Sequence) – list or tuple for the graph inputs
- Returns
updated globa/state attributes
- phi_v(b_ei_p, inputs)[source]¶
Node update function :param b_ei_p: edge aggregated tensor :type b_ei_p: tensor :param inputs: other graph inputs :type inputs: tuple of tensors
Returns: updated node tensor
- rho_e_u(e_p, inputs)[source]¶
aggregate edge to state :param e_p: edge tensor :type e_p: tensor :param inputs: other graph input tensors :type inputs: tuple of tensors
Returns: edge aggregated tensor for states