Skip to content

Temporal layers

graphs_on_grids.layers.temporal.base #

GraphBaseConvLSTM #

Bases: GraphConvLSTM

Implementation of a GraphConvLSTM layer using a GraphBase layer as graph layer. See the documentation on how temporal layers work.

Source code in graphs_on_grids/layers/temporal/base.py
class GraphBaseConvLSTM(GraphConvLSTM):
    """
    Implementation of a `GraphConvLSTM` layer using a `GraphBase` layer as graph layer.
    See the [documentation](/usage/temporal_layers) on how temporal layers work.
    """

    def __init__(
        self,
        adjacency_matrix: np.ndarray,
        embedding_size: int,
        hidden_units_node: list | tuple = None,
        hidden_units_edge: list | tuple = None,
        dropout_rate: int | float = 0,
        use_bias: bool = True,
        activation: str | None = None,
        weight_initializer: str
        | keras.initializers.Initializer
        | None = "glorot_uniform",
        weight_regularizer: str | keras.regularizers.Regularizer | None = None,
        bias_initializer: str | keras.initializers.Initializer | None = "zeros",
    ):
        """
        :param adjacency_matrix: adjacency matrix of the graphs to be passed to the model
        :param embedding_size: the output dimensionality of the node feature vector
        :param hidden_units_node: list or tuple of neuron counts in the hidden layers used in the MLP for processing
        node features
        :param hidden_units_edge: list or tuple of neuron counts in the hidden layers used in the MLP for processing
        edge features
        :param dropout_rate: The dropout rate used after each dense layer in the node- or edge-MLPs
        :param use_bias: Whether to use bias in the hidden layers in the node- and edge-MLPs
        :param activation: Activation function to be used within the layer
        :param weight_initializer: Weight initializer to be used within the layer
        :param weight_regularizer: Weight regularizer to be used within the layer
        :param bias_initializer: Bias initializer to be used within the layer
        """
        super(GraphBaseConvLSTM, self).__init__(
            adjacency_matrix=adjacency_matrix,
            embedding_size=embedding_size,
            hidden_units_node=hidden_units_node,
            hidden_units_edge=hidden_units_edge,
            dropout_rate=dropout_rate,
            use_bias=use_bias,
            activation=activation,
            weight_initializer=weight_initializer,
            weight_regularizer=weight_regularizer,
            bias_initializer=bias_initializer,
        )

    def build(self, input_shape):
        super().build(input_shape)
        self.graph_layer = GraphBase(
            adjacency_matrix=self.adjacency_matrix,
            embedding_size=self.embedding_size,
            hidden_units_node=self.hidden_units_node,
            hidden_units_edge=self.hidden_units_edge,
            dropout_rate=self.dropout_rate,
            use_bias=self.use_bias,
            activation=self.activation,
            weight_initializer=self.weight_initializer,
            weight_regularizer=self.weight_regularizer,
            bias_initializer=self.bias_initializer,
        )

__init__(adjacency_matrix, embedding_size, hidden_units_node=None, hidden_units_edge=None, dropout_rate=0, use_bias=True, activation=None, weight_initializer='glorot_uniform', weight_regularizer=None, bias_initializer='zeros') #

Parameters:

Name Type Description Default
adjacency_matrix ndarray

adjacency matrix of the graphs to be passed to the model

required
embedding_size int

the output dimensionality of the node feature vector

required
hidden_units_node list | tuple

list or tuple of neuron counts in the hidden layers used in the MLP for processing node features

None
hidden_units_edge list | tuple

list or tuple of neuron counts in the hidden layers used in the MLP for processing edge features

None
dropout_rate int | float

The dropout rate used after each dense layer in the node- or edge-MLPs

0
use_bias bool

Whether to use bias in the hidden layers in the node- and edge-MLPs

True
activation str | None

Activation function to be used within the layer

None
weight_initializer str | Initializer | None

Weight initializer to be used within the layer

'glorot_uniform'
weight_regularizer str | Regularizer | None

Weight regularizer to be used within the layer

None
bias_initializer str | Initializer | None

Bias initializer to be used within the layer

'zeros'
Source code in graphs_on_grids/layers/temporal/base.py
def __init__(
    self,
    adjacency_matrix: np.ndarray,
    embedding_size: int,
    hidden_units_node: list | tuple = None,
    hidden_units_edge: list | tuple = None,
    dropout_rate: int | float = 0,
    use_bias: bool = True,
    activation: str | None = None,
    weight_initializer: str
    | keras.initializers.Initializer
    | None = "glorot_uniform",
    weight_regularizer: str | keras.regularizers.Regularizer | None = None,
    bias_initializer: str | keras.initializers.Initializer | None = "zeros",
):
    """
    :param adjacency_matrix: adjacency matrix of the graphs to be passed to the model
    :param embedding_size: the output dimensionality of the node feature vector
    :param hidden_units_node: list or tuple of neuron counts in the hidden layers used in the MLP for processing
    node features
    :param hidden_units_edge: list or tuple of neuron counts in the hidden layers used in the MLP for processing
    edge features
    :param dropout_rate: The dropout rate used after each dense layer in the node- or edge-MLPs
    :param use_bias: Whether to use bias in the hidden layers in the node- and edge-MLPs
    :param activation: Activation function to be used within the layer
    :param weight_initializer: Weight initializer to be used within the layer
    :param weight_regularizer: Weight regularizer to be used within the layer
    :param bias_initializer: Bias initializer to be used within the layer
    """
    super(GraphBaseConvLSTM, self).__init__(
        adjacency_matrix=adjacency_matrix,
        embedding_size=embedding_size,
        hidden_units_node=hidden_units_node,
        hidden_units_edge=hidden_units_edge,
        dropout_rate=dropout_rate,
        use_bias=use_bias,
        activation=activation,
        weight_initializer=weight_initializer,
        weight_regularizer=weight_regularizer,
        bias_initializer=bias_initializer,
    )

GraphBaseGRU #

Bases: GraphGRU

Implementation of a GraphGRU layer using a GraphBase layer as graph layer. See the documentation on how temporal layers work.

Source code in graphs_on_grids/layers/temporal/base.py
class GraphBaseGRU(GraphGRU):
    """
    Implementation of a `GraphGRU` layer using a `GraphBase` layer as graph layer.
    See the [documentation](/usage/temporal_layers) on how temporal layers work.
    """

    def __init__(
        self,
        adjacency_matrix: np.ndarray,
        embedding_size: int,
        hidden_units_node: list | tuple = None,
        hidden_units_edge: list | tuple = None,
        dropout_rate: int | float = 0,
        use_bias: bool = True,
        activation: str | None = None,
        weight_initializer: str
        | keras.initializers.Initializer
        | None = "glorot_uniform",
        weight_regularizer: str | keras.regularizers.Regularizer | None = None,
        bias_initializer: str | keras.initializers.Initializer | None = "zeros",
    ):
        """
        :param adjacency_matrix: adjacency matrix of the graphs to be passed to the model
        :param embedding_size: the output dimensionality of the node feature vector
        :param hidden_units_node: list or tuple of neuron counts in the hidden layers used in the MLP for processing
        node features
        :param hidden_units_edge: list or tuple of neuron counts in the hidden layers used in the MLP for processing
        edge features
        :param dropout_rate: The dropout rate used after each dense layer in the node- or edge-MLPs
        :param use_bias: Whether to use bias in the hidden layers in the node- and edge-MLPs
        :param activation: Activation function to be used within the layer
        :param weight_initializer: Weight initializer to be used within the layer
        :param weight_regularizer: Weight regularizer to be used within the layer
        :param bias_initializer: Bias initializer to be used within the layer
        """
        super(GraphBaseGRU, self).__init__(
            adjacency_matrix=adjacency_matrix,
            embedding_size=embedding_size,
            hidden_units_node=hidden_units_node,
            hidden_units_edge=hidden_units_edge,
            dropout_rate=dropout_rate,
            use_bias=use_bias,
            activation=activation,
            weight_initializer=weight_initializer,
            weight_regularizer=weight_regularizer,
            bias_initializer=bias_initializer,
        )

    def build(self, input_shape):
        super().build(input_shape)
        self.graph_layer = GraphBase(
            adjacency_matrix=self.adjacency_matrix,
            embedding_size=self.embedding_size,
            hidden_units_node=self.hidden_units_node,
            hidden_units_edge=self.hidden_units_edge,
            dropout_rate=self.dropout_rate,
            use_bias=self.use_bias,
            activation=self.activation,
            weight_initializer=self.weight_initializer,
            weight_regularizer=self.weight_regularizer,
            bias_initializer=self.bias_initializer,
        )

__init__(adjacency_matrix, embedding_size, hidden_units_node=None, hidden_units_edge=None, dropout_rate=0, use_bias=True, activation=None, weight_initializer='glorot_uniform', weight_regularizer=None, bias_initializer='zeros') #

Parameters:

Name Type Description Default
adjacency_matrix ndarray

adjacency matrix of the graphs to be passed to the model

required
embedding_size int

the output dimensionality of the node feature vector

required
hidden_units_node list | tuple

list or tuple of neuron counts in the hidden layers used in the MLP for processing node features

None
hidden_units_edge list | tuple

list or tuple of neuron counts in the hidden layers used in the MLP for processing edge features

None
dropout_rate int | float

The dropout rate used after each dense layer in the node- or edge-MLPs

0
use_bias bool

Whether to use bias in the hidden layers in the node- and edge-MLPs

True
activation str | None

Activation function to be used within the layer

None
weight_initializer str | Initializer | None

Weight initializer to be used within the layer

'glorot_uniform'
weight_regularizer str | Regularizer | None

Weight regularizer to be used within the layer

None
bias_initializer str | Initializer | None

Bias initializer to be used within the layer

'zeros'
Source code in graphs_on_grids/layers/temporal/base.py
def __init__(
    self,
    adjacency_matrix: np.ndarray,
    embedding_size: int,
    hidden_units_node: list | tuple = None,
    hidden_units_edge: list | tuple = None,
    dropout_rate: int | float = 0,
    use_bias: bool = True,
    activation: str | None = None,
    weight_initializer: str
    | keras.initializers.Initializer
    | None = "glorot_uniform",
    weight_regularizer: str | keras.regularizers.Regularizer | None = None,
    bias_initializer: str | keras.initializers.Initializer | None = "zeros",
):
    """
    :param adjacency_matrix: adjacency matrix of the graphs to be passed to the model
    :param embedding_size: the output dimensionality of the node feature vector
    :param hidden_units_node: list or tuple of neuron counts in the hidden layers used in the MLP for processing
    node features
    :param hidden_units_edge: list or tuple of neuron counts in the hidden layers used in the MLP for processing
    edge features
    :param dropout_rate: The dropout rate used after each dense layer in the node- or edge-MLPs
    :param use_bias: Whether to use bias in the hidden layers in the node- and edge-MLPs
    :param activation: Activation function to be used within the layer
    :param weight_initializer: Weight initializer to be used within the layer
    :param weight_regularizer: Weight regularizer to be used within the layer
    :param bias_initializer: Bias initializer to be used within the layer
    """
    super(GraphBaseGRU, self).__init__(
        adjacency_matrix=adjacency_matrix,
        embedding_size=embedding_size,
        hidden_units_node=hidden_units_node,
        hidden_units_edge=hidden_units_edge,
        dropout_rate=dropout_rate,
        use_bias=use_bias,
        activation=activation,
        weight_initializer=weight_initializer,
        weight_regularizer=weight_regularizer,
        bias_initializer=bias_initializer,
    )

GraphBaseLSTM #

Bases: GraphLSTM

Implementation of a GraphLSTM layer using a GraphBase layer as graph layer. See the documentation on how temporal layers work.

Source code in graphs_on_grids/layers/temporal/base.py
class GraphBaseLSTM(GraphLSTM):
    """
    Implementation of a `GraphLSTM` layer using a `GraphBase` layer as graph layer.
    See the [documentation](/usage/temporal_layers) on how temporal layers work.
    """

    def __init__(
        self,
        adjacency_matrix: np.ndarray,
        embedding_size: int,
        hidden_units_node: list | tuple = None,
        hidden_units_edge: list | tuple = None,
        dropout_rate: int | float = 0,
        use_bias: bool = True,
        activation: str | None = None,
        weight_initializer: str
        | keras.initializers.Initializer
        | None = "glorot_uniform",
        weight_regularizer: str | keras.regularizers.Regularizer | None = None,
        bias_initializer: str | keras.initializers.Initializer | None = "zeros",
    ):
        """
        :param adjacency_matrix: adjacency matrix of the graphs to be passed to the model
        :param embedding_size: the output dimensionality of the node feature vector
        :param hidden_units_node: list or tuple of neuron counts in the hidden layers used in the MLP for processing
        node features
        :param hidden_units_edge: list or tuple of neuron counts in the hidden layers used in the MLP for processing
        edge features
        :param dropout_rate: The dropout rate used after each dense layer in the node- or edge-MLPs
        :param use_bias: Whether to use bias in the hidden layers in the node- and edge-MLPs
        :param activation: Activation function to be used within the layer
        :param weight_initializer: Weight initializer to be used within the layer
        :param weight_regularizer: Weight regularizer to be used within the layer
        :param bias_initializer: Bias initializer to be used within the layer
        """
        super(GraphBaseLSTM, self).__init__(
            adjacency_matrix=adjacency_matrix,
            embedding_size=embedding_size,
            hidden_units_node=hidden_units_node,
            hidden_units_edge=hidden_units_edge,
            dropout_rate=dropout_rate,
            use_bias=use_bias,
            activation=activation,
            weight_initializer=weight_initializer,
            weight_regularizer=weight_regularizer,
            bias_initializer=bias_initializer,
        )

    def build(self, input_shape):
        super().build(input_shape)
        self.graph_layer = GraphBase(
            adjacency_matrix=self.adjacency_matrix,
            embedding_size=self.embedding_size,
            hidden_units_node=self.hidden_units_node,
            hidden_units_edge=self.hidden_units_edge,
            dropout_rate=self.dropout_rate,
            use_bias=self.use_bias,
            activation=self.activation,
            weight_initializer=self.weight_initializer,
            weight_regularizer=self.weight_regularizer,
            bias_initializer=self.bias_initializer,
        )

__init__(adjacency_matrix, embedding_size, hidden_units_node=None, hidden_units_edge=None, dropout_rate=0, use_bias=True, activation=None, weight_initializer='glorot_uniform', weight_regularizer=None, bias_initializer='zeros') #

Parameters:

Name Type Description Default
adjacency_matrix ndarray

adjacency matrix of the graphs to be passed to the model

required
embedding_size int

the output dimensionality of the node feature vector

required
hidden_units_node list | tuple

list or tuple of neuron counts in the hidden layers used in the MLP for processing node features

None
hidden_units_edge list | tuple

list or tuple of neuron counts in the hidden layers used in the MLP for processing edge features

None
dropout_rate int | float

The dropout rate used after each dense layer in the node- or edge-MLPs

0
use_bias bool

Whether to use bias in the hidden layers in the node- and edge-MLPs

True
activation str | None

Activation function to be used within the layer

None
weight_initializer str | Initializer | None

Weight initializer to be used within the layer

'glorot_uniform'
weight_regularizer str | Regularizer | None

Weight regularizer to be used within the layer

None
bias_initializer str | Initializer | None

Bias initializer to be used within the layer

'zeros'
Source code in graphs_on_grids/layers/temporal/base.py
def __init__(
    self,
    adjacency_matrix: np.ndarray,
    embedding_size: int,
    hidden_units_node: list | tuple = None,
    hidden_units_edge: list | tuple = None,
    dropout_rate: int | float = 0,
    use_bias: bool = True,
    activation: str | None = None,
    weight_initializer: str
    | keras.initializers.Initializer
    | None = "glorot_uniform",
    weight_regularizer: str | keras.regularizers.Regularizer | None = None,
    bias_initializer: str | keras.initializers.Initializer | None = "zeros",
):
    """
    :param adjacency_matrix: adjacency matrix of the graphs to be passed to the model
    :param embedding_size: the output dimensionality of the node feature vector
    :param hidden_units_node: list or tuple of neuron counts in the hidden layers used in the MLP for processing
    node features
    :param hidden_units_edge: list or tuple of neuron counts in the hidden layers used in the MLP for processing
    edge features
    :param dropout_rate: The dropout rate used after each dense layer in the node- or edge-MLPs
    :param use_bias: Whether to use bias in the hidden layers in the node- and edge-MLPs
    :param activation: Activation function to be used within the layer
    :param weight_initializer: Weight initializer to be used within the layer
    :param weight_regularizer: Weight regularizer to be used within the layer
    :param bias_initializer: Bias initializer to be used within the layer
    """
    super(GraphBaseLSTM, self).__init__(
        adjacency_matrix=adjacency_matrix,
        embedding_size=embedding_size,
        hidden_units_node=hidden_units_node,
        hidden_units_edge=hidden_units_edge,
        dropout_rate=dropout_rate,
        use_bias=use_bias,
        activation=activation,
        weight_initializer=weight_initializer,
        weight_regularizer=weight_regularizer,
        bias_initializer=bias_initializer,
    )

GraphBaseTemporalConv #

Bases: TemporalConv

Implementation of a TemporalConv layer using a GraphBase layer as graph layer. See the documentation on how temporal layers work.

Source code in graphs_on_grids/layers/temporal/base.py
class GraphBaseTemporalConv(TemporalConv):
    """
    Implementation of a `TemporalConv` layer using a `GraphBase` layer as graph layer.
    See the [documentation](/usage/temporal_layers) on how temporal layers work.
    """

    def __init__(
        self,
        adjacency_matrix: np.ndarray,
        embedding_size: int,
        output_seq_len: int,
        hidden_units_node: list | tuple = None,
        hidden_units_edge: list | tuple = None,
        dropout_rate: int | float = 0,
        use_bias: bool = True,
        activation: str | None = None,
        weight_initializer: str
        | keras.initializers.Initializer
        | None = "glorot_uniform",
        weight_regularizer: str | keras.regularizers.Regularizer | None = None,
        bias_initializer: str | keras.initializers.Initializer | None = "zeros",
    ):
        """
        :param adjacency_matrix: adjacency matrix of the graphs to be passed to the model
        :param embedding_size: the output dimensionality of the node feature vector
        :param output_seq_len: number of graphs in the output sequence
        :param hidden_units_node: list or tuple of neuron counts in the hidden layers used in the MLP for processing
        node features
        :param hidden_units_edge: list or tuple of neuron counts in the hidden layers used in the MLP for processing
        edge features
        :param dropout_rate: The dropout rate used after each dense layer in the node- or edge-MLPs
        :param use_bias: Whether to use bias in the hidden layers in the node- and edge-MLPs
        :param activation: Activation function to be used within the layer
        :param weight_initializer: Weight initializer to be used within the layer
        :param weight_regularizer: Weight regularizer to be used within the layer
        :param bias_initializer: Bias initializer to be used within the layer
        """
        super(GraphBaseTemporalConv, self).__init__(
            adjacency_matrix=adjacency_matrix,
            embedding_size=embedding_size,
            output_seq_len=output_seq_len,
            hidden_units_node=hidden_units_node,
            hidden_units_edge=hidden_units_edge,
            dropout_rate=dropout_rate,
            use_bias=use_bias,
            activation=activation,
            weight_initializer=weight_initializer,
            weight_regularizer=weight_regularizer,
            bias_initializer=bias_initializer,
        )

    def build(self, input_shape):
        super().build(input_shape=input_shape)
        self.graph_layer = GraphBase(
            adjacency_matrix=self.adjacency_matrix,
            embedding_size=self.embedding_size,
            hidden_units_node=self.hidden_units_node,
            hidden_units_edge=self.hidden_units_edge,
            dropout_rate=self.dropout_rate,
            use_bias=self.use_bias,
            activation=self.activation,
            weight_initializer=self.weight_initializer,
            weight_regularizer=self.weight_regularizer,
            bias_initializer=self.bias_initializer,
        )

__init__(adjacency_matrix, embedding_size, output_seq_len, hidden_units_node=None, hidden_units_edge=None, dropout_rate=0, use_bias=True, activation=None, weight_initializer='glorot_uniform', weight_regularizer=None, bias_initializer='zeros') #

Parameters:

Name Type Description Default
adjacency_matrix ndarray

adjacency matrix of the graphs to be passed to the model

required
embedding_size int

the output dimensionality of the node feature vector

required
output_seq_len int

number of graphs in the output sequence

required
hidden_units_node list | tuple

list or tuple of neuron counts in the hidden layers used in the MLP for processing node features

None
hidden_units_edge list | tuple

list or tuple of neuron counts in the hidden layers used in the MLP for processing edge features

None
dropout_rate int | float

The dropout rate used after each dense layer in the node- or edge-MLPs

0
use_bias bool

Whether to use bias in the hidden layers in the node- and edge-MLPs

True
activation str | None

Activation function to be used within the layer

None
weight_initializer str | Initializer | None

Weight initializer to be used within the layer

'glorot_uniform'
weight_regularizer str | Regularizer | None

Weight regularizer to be used within the layer

None
bias_initializer str | Initializer | None

Bias initializer to be used within the layer

'zeros'
Source code in graphs_on_grids/layers/temporal/base.py
def __init__(
    self,
    adjacency_matrix: np.ndarray,
    embedding_size: int,
    output_seq_len: int,
    hidden_units_node: list | tuple = None,
    hidden_units_edge: list | tuple = None,
    dropout_rate: int | float = 0,
    use_bias: bool = True,
    activation: str | None = None,
    weight_initializer: str
    | keras.initializers.Initializer
    | None = "glorot_uniform",
    weight_regularizer: str | keras.regularizers.Regularizer | None = None,
    bias_initializer: str | keras.initializers.Initializer | None = "zeros",
):
    """
    :param adjacency_matrix: adjacency matrix of the graphs to be passed to the model
    :param embedding_size: the output dimensionality of the node feature vector
    :param output_seq_len: number of graphs in the output sequence
    :param hidden_units_node: list or tuple of neuron counts in the hidden layers used in the MLP for processing
    node features
    :param hidden_units_edge: list or tuple of neuron counts in the hidden layers used in the MLP for processing
    edge features
    :param dropout_rate: The dropout rate used after each dense layer in the node- or edge-MLPs
    :param use_bias: Whether to use bias in the hidden layers in the node- and edge-MLPs
    :param activation: Activation function to be used within the layer
    :param weight_initializer: Weight initializer to be used within the layer
    :param weight_regularizer: Weight regularizer to be used within the layer
    :param bias_initializer: Bias initializer to be used within the layer
    """
    super(GraphBaseTemporalConv, self).__init__(
        adjacency_matrix=adjacency_matrix,
        embedding_size=embedding_size,
        output_seq_len=output_seq_len,
        hidden_units_node=hidden_units_node,
        hidden_units_edge=hidden_units_edge,
        dropout_rate=dropout_rate,
        use_bias=use_bias,
        activation=activation,
        weight_initializer=weight_initializer,
        weight_regularizer=weight_regularizer,
        bias_initializer=bias_initializer,
    )

graphs_on_grids.layers.temporal.conv #

GraphConvTemporalConv #

Bases: TemporalConv

Implementation of a TemporalConv layer using a GraphConvolution layer as graph layer. See the documentation on how temporal layers work.

Source code in graphs_on_grids/layers/temporal/conv.py
class GraphConvTemporalConv(TemporalConv):
    """
    Implementation of a `TemporalConv` layer using a `GraphConvolution` layer as graph layer.
    See the [documentation](/usage/temporal_layers) on how temporal layers work.
    """

    def __init__(
        self,
        adjacency_matrix: np.ndarray,
        embedding_size: int,
        output_seq_len: int,
        hidden_units_node: list | tuple = None,
        hidden_units_edge: list | tuple = None,
        dropout_rate: int | float = 0,
        use_bias: bool = True,
        activation: str | None = None,
        weight_initializer: str
        | keras.initializers.Initializer
        | None = "glorot_uniform",
        weight_regularizer: str | keras.regularizers.Regularizer | None = None,
        bias_initializer: str | keras.initializers.Initializer | None = "zeros",
    ):
        """
        :param adjacency_matrix: adjacency matrix of the graphs to be passed to the model
        :param embedding_size: the output dimensionality of the node feature vector
        :param output_seq_len: number of graphs in the output sequence
        :param hidden_units_node: list or tuple of neuron counts in the hidden layers used in the MLP for processing
        node features
        :param hidden_units_edge: list or tuple of neuron counts in the hidden layers used in the MLP for processing
        edge features
        :param dropout_rate: The dropout rate used after each dense layer in the node- or edge-MLPs
        :param use_bias: Whether to use bias in the hidden layers in the node- and edge-MLPs
        :param activation: Activation function to be used within the layer
        :param weight_initializer: Weight initializer to be used within the layer
        :param weight_regularizer: Weight regularizer to be used within the layer
        :param bias_initializer: Bias initializer to be used within the layer
        """
        super(GraphConvTemporalConv, self).__init__(
            adjacency_matrix=adjacency_matrix,
            embedding_size=embedding_size,
            output_seq_len=output_seq_len,
            hidden_units_node=hidden_units_node,
            hidden_units_edge=hidden_units_edge,
            dropout_rate=dropout_rate,
            use_bias=use_bias,
            activation=activation,
            weight_initializer=weight_initializer,
            weight_regularizer=weight_regularizer,
            bias_initializer=bias_initializer,
        )

    def build(self, input_shape):
        super().build(input_shape=input_shape)
        self.graph_layer = GraphConvolution(
            adjacency_matrix=self.adjacency_matrix,
            embedding_size=self.embedding_size,
            hidden_units_node=self.hidden_units_node,
            hidden_units_edge=self.hidden_units_edge,
            dropout_rate=self.dropout_rate,
            use_bias=self.use_bias,
            activation=self.activation,
            weight_initializer=self.weight_initializer,
            weight_regularizer=self.weight_regularizer,
            bias_initializer=self.bias_initializer,
        )

__init__(adjacency_matrix, embedding_size, output_seq_len, hidden_units_node=None, hidden_units_edge=None, dropout_rate=0, use_bias=True, activation=None, weight_initializer='glorot_uniform', weight_regularizer=None, bias_initializer='zeros') #

Parameters:

Name Type Description Default
adjacency_matrix ndarray

adjacency matrix of the graphs to be passed to the model

required
embedding_size int

the output dimensionality of the node feature vector

required
output_seq_len int

number of graphs in the output sequence

required
hidden_units_node list | tuple

list or tuple of neuron counts in the hidden layers used in the MLP for processing node features

None
hidden_units_edge list | tuple

list or tuple of neuron counts in the hidden layers used in the MLP for processing edge features

None
dropout_rate int | float

The dropout rate used after each dense layer in the node- or edge-MLPs

0
use_bias bool

Whether to use bias in the hidden layers in the node- and edge-MLPs

True
activation str | None

Activation function to be used within the layer

None
weight_initializer str | Initializer | None

Weight initializer to be used within the layer

'glorot_uniform'
weight_regularizer str | Regularizer | None

Weight regularizer to be used within the layer

None
bias_initializer str | Initializer | None

Bias initializer to be used within the layer

'zeros'
Source code in graphs_on_grids/layers/temporal/conv.py
def __init__(
    self,
    adjacency_matrix: np.ndarray,
    embedding_size: int,
    output_seq_len: int,
    hidden_units_node: list | tuple = None,
    hidden_units_edge: list | tuple = None,
    dropout_rate: int | float = 0,
    use_bias: bool = True,
    activation: str | None = None,
    weight_initializer: str
    | keras.initializers.Initializer
    | None = "glorot_uniform",
    weight_regularizer: str | keras.regularizers.Regularizer | None = None,
    bias_initializer: str | keras.initializers.Initializer | None = "zeros",
):
    """
    :param adjacency_matrix: adjacency matrix of the graphs to be passed to the model
    :param embedding_size: the output dimensionality of the node feature vector
    :param output_seq_len: number of graphs in the output sequence
    :param hidden_units_node: list or tuple of neuron counts in the hidden layers used in the MLP for processing
    node features
    :param hidden_units_edge: list or tuple of neuron counts in the hidden layers used in the MLP for processing
    edge features
    :param dropout_rate: The dropout rate used after each dense layer in the node- or edge-MLPs
    :param use_bias: Whether to use bias in the hidden layers in the node- and edge-MLPs
    :param activation: Activation function to be used within the layer
    :param weight_initializer: Weight initializer to be used within the layer
    :param weight_regularizer: Weight regularizer to be used within the layer
    :param bias_initializer: Bias initializer to be used within the layer
    """
    super(GraphConvTemporalConv, self).__init__(
        adjacency_matrix=adjacency_matrix,
        embedding_size=embedding_size,
        output_seq_len=output_seq_len,
        hidden_units_node=hidden_units_node,
        hidden_units_edge=hidden_units_edge,
        dropout_rate=dropout_rate,
        use_bias=use_bias,
        activation=activation,
        weight_initializer=weight_initializer,
        weight_regularizer=weight_regularizer,
        bias_initializer=bias_initializer,
    )

GraphConvolutionConvLSTM #

Bases: GraphConvLSTM

Implementation of a GraphConvLSTM layer using a GraphConvolution layer as graph layer. See the documentation on how temporal layers work.

Source code in graphs_on_grids/layers/temporal/conv.py
class GraphConvolutionConvLSTM(GraphConvLSTM):
    """
    Implementation of a `GraphConvLSTM` layer using a `GraphConvolution` layer as graph layer.
    See the [documentation](/usage/temporal_layers) on how temporal layers work.
    """

    def __init__(
        self,
        adjacency_matrix: np.ndarray,
        embedding_size: int,
        hidden_units_node: list | tuple = None,
        hidden_units_edge: list | tuple = None,
        dropout_rate: int | float = 0,
        use_bias: bool = True,
        activation: str | None = None,
        weight_initializer: str
        | keras.initializers.Initializer
        | None = "glorot_uniform",
        weight_regularizer: str | keras.regularizers.Regularizer | None = None,
        bias_initializer: str | keras.initializers.Initializer | None = "zeros",
    ):
        """
        :param adjacency_matrix: adjacency matrix of the graphs to be passed to the model
        :param embedding_size: the output dimensionality of the node feature vector
        :param hidden_units_node: list or tuple of neuron counts in the hidden layers used in the MLP for processing
        node features
        :param hidden_units_edge: list or tuple of neuron counts in the hidden layers used in the MLP for processing
        edge features
        :param dropout_rate: The dropout rate used after each dense layer in the node- or edge-MLPs
        :param use_bias: Whether to use bias in the hidden layers in the node- and edge-MLPs
        :param activation: Activation function to be used within the layer
        :param weight_initializer: Weight initializer to be used within the layer
        :param weight_regularizer: Weight regularizer to be used within the layer
        :param bias_initializer: Bias initializer to be used within the layer
        """
        super(GraphConvolutionConvLSTM, self).__init__(
            adjacency_matrix=adjacency_matrix,
            embedding_size=embedding_size,
            hidden_units_node=hidden_units_node,
            hidden_units_edge=hidden_units_edge,
            dropout_rate=dropout_rate,
            use_bias=use_bias,
            activation=activation,
            weight_initializer=weight_initializer,
            weight_regularizer=weight_regularizer,
            bias_initializer=bias_initializer,
        )

    def build(self, input_shape):
        super().build(input_shape)
        self.graph_layer = GraphConvolution(
            adjacency_matrix=self.adjacency_matrix,
            embedding_size=self.embedding_size,
            hidden_units_node=self.hidden_units_node,
            hidden_units_edge=self.hidden_units_edge,
            dropout_rate=self.dropout_rate,
            use_bias=self.use_bias,
            activation=self.activation,
            weight_initializer=self.weight_initializer,
            weight_regularizer=self.weight_regularizer,
            bias_initializer=self.bias_initializer,
        )

__init__(adjacency_matrix, embedding_size, hidden_units_node=None, hidden_units_edge=None, dropout_rate=0, use_bias=True, activation=None, weight_initializer='glorot_uniform', weight_regularizer=None, bias_initializer='zeros') #

Parameters:

Name Type Description Default
adjacency_matrix ndarray

adjacency matrix of the graphs to be passed to the model

required
embedding_size int

the output dimensionality of the node feature vector

required
hidden_units_node list | tuple

list or tuple of neuron counts in the hidden layers used in the MLP for processing node features

None
hidden_units_edge list | tuple

list or tuple of neuron counts in the hidden layers used in the MLP for processing edge features

None
dropout_rate int | float

The dropout rate used after each dense layer in the node- or edge-MLPs

0
use_bias bool

Whether to use bias in the hidden layers in the node- and edge-MLPs

True
activation str | None

Activation function to be used within the layer

None
weight_initializer str | Initializer | None

Weight initializer to be used within the layer

'glorot_uniform'
weight_regularizer str | Regularizer | None

Weight regularizer to be used within the layer

None
bias_initializer str | Initializer | None

Bias initializer to be used within the layer

'zeros'
Source code in graphs_on_grids/layers/temporal/conv.py
def __init__(
    self,
    adjacency_matrix: np.ndarray,
    embedding_size: int,
    hidden_units_node: list | tuple = None,
    hidden_units_edge: list | tuple = None,
    dropout_rate: int | float = 0,
    use_bias: bool = True,
    activation: str | None = None,
    weight_initializer: str
    | keras.initializers.Initializer
    | None = "glorot_uniform",
    weight_regularizer: str | keras.regularizers.Regularizer | None = None,
    bias_initializer: str | keras.initializers.Initializer | None = "zeros",
):
    """
    :param adjacency_matrix: adjacency matrix of the graphs to be passed to the model
    :param embedding_size: the output dimensionality of the node feature vector
    :param hidden_units_node: list or tuple of neuron counts in the hidden layers used in the MLP for processing
    node features
    :param hidden_units_edge: list or tuple of neuron counts in the hidden layers used in the MLP for processing
    edge features
    :param dropout_rate: The dropout rate used after each dense layer in the node- or edge-MLPs
    :param use_bias: Whether to use bias in the hidden layers in the node- and edge-MLPs
    :param activation: Activation function to be used within the layer
    :param weight_initializer: Weight initializer to be used within the layer
    :param weight_regularizer: Weight regularizer to be used within the layer
    :param bias_initializer: Bias initializer to be used within the layer
    """
    super(GraphConvolutionConvLSTM, self).__init__(
        adjacency_matrix=adjacency_matrix,
        embedding_size=embedding_size,
        hidden_units_node=hidden_units_node,
        hidden_units_edge=hidden_units_edge,
        dropout_rate=dropout_rate,
        use_bias=use_bias,
        activation=activation,
        weight_initializer=weight_initializer,
        weight_regularizer=weight_regularizer,
        bias_initializer=bias_initializer,
    )

GraphConvolutionGRU #

Bases: GraphGRU

Implementation of a GraphGRU layer using a GraphConvolution layer as graph layer. See the documentation on how temporal layers work.

Source code in graphs_on_grids/layers/temporal/conv.py
class GraphConvolutionGRU(GraphGRU):
    """
    Implementation of a `GraphGRU` layer using a `GraphConvolution` layer as graph layer.
    See the [documentation](/usage/temporal_layers) on how temporal layers work.
    """

    def __init__(
        self,
        adjacency_matrix: np.ndarray,
        embedding_size: int,
        hidden_units_node: list | tuple = None,
        hidden_units_edge: list | tuple = None,
        dropout_rate: int | float = 0,
        use_bias: bool = True,
        activation: str | None = None,
        weight_initializer: str
        | keras.initializers.Initializer
        | None = "glorot_uniform",
        weight_regularizer: str | keras.regularizers.Regularizer | None = None,
        bias_initializer: str | keras.initializers.Initializer | None = "zeros",
    ):
        """
        :param adjacency_matrix: adjacency matrix of the graphs to be passed to the model
        :param embedding_size: the output dimensionality of the node feature vector
        :param hidden_units_node: list or tuple of neuron counts in the hidden layers used in the MLP for processing
        node features
        :param hidden_units_edge: list or tuple of neuron counts in the hidden layers used in the MLP for processing
        edge features
        :param dropout_rate: The dropout rate used after each dense layer in the node- or edge-MLPs
        :param use_bias: Whether to use bias in the hidden layers in the node- and edge-MLPs
        :param activation: Activation function to be used within the layer
        :param weight_initializer: Weight initializer to be used within the layer
        :param weight_regularizer: Weight regularizer to be used within the layer
        :param bias_initializer: Bias initializer to be used within the layer
        """
        super(GraphConvolutionGRU, self).__init__(
            adjacency_matrix=adjacency_matrix,
            embedding_size=embedding_size,
            hidden_units_node=hidden_units_node,
            hidden_units_edge=hidden_units_edge,
            dropout_rate=dropout_rate,
            use_bias=use_bias,
            activation=activation,
            weight_initializer=weight_initializer,
            weight_regularizer=weight_regularizer,
            bias_initializer=bias_initializer,
        )

    def build(self, input_shape):
        super().build(input_shape)
        self.graph_layer = GraphConvolution(
            adjacency_matrix=self.adjacency_matrix,
            embedding_size=self.embedding_size,
            hidden_units_node=self.hidden_units_node,
            hidden_units_edge=self.hidden_units_edge,
            dropout_rate=self.dropout_rate,
            use_bias=self.use_bias,
            activation=self.activation,
            weight_initializer=self.weight_initializer,
            weight_regularizer=self.weight_regularizer,
            bias_initializer=self.bias_initializer,
        )

__init__(adjacency_matrix, embedding_size, hidden_units_node=None, hidden_units_edge=None, dropout_rate=0, use_bias=True, activation=None, weight_initializer='glorot_uniform', weight_regularizer=None, bias_initializer='zeros') #

Parameters:

Name Type Description Default
adjacency_matrix ndarray

adjacency matrix of the graphs to be passed to the model

required
embedding_size int

the output dimensionality of the node feature vector

required
hidden_units_node list | tuple

list or tuple of neuron counts in the hidden layers used in the MLP for processing node features

None
hidden_units_edge list | tuple

list or tuple of neuron counts in the hidden layers used in the MLP for processing edge features

None
dropout_rate int | float

The dropout rate used after each dense layer in the node- or edge-MLPs

0
use_bias bool

Whether to use bias in the hidden layers in the node- and edge-MLPs

True
activation str | None

Activation function to be used within the layer

None
weight_initializer str | Initializer | None

Weight initializer to be used within the layer

'glorot_uniform'
weight_regularizer str | Regularizer | None

Weight regularizer to be used within the layer

None
bias_initializer str | Initializer | None

Bias initializer to be used within the layer

'zeros'
Source code in graphs_on_grids/layers/temporal/conv.py
def __init__(
    self,
    adjacency_matrix: np.ndarray,
    embedding_size: int,
    hidden_units_node: list | tuple = None,
    hidden_units_edge: list | tuple = None,
    dropout_rate: int | float = 0,
    use_bias: bool = True,
    activation: str | None = None,
    weight_initializer: str
    | keras.initializers.Initializer
    | None = "glorot_uniform",
    weight_regularizer: str | keras.regularizers.Regularizer | None = None,
    bias_initializer: str | keras.initializers.Initializer | None = "zeros",
):
    """
    :param adjacency_matrix: adjacency matrix of the graphs to be passed to the model
    :param embedding_size: the output dimensionality of the node feature vector
    :param hidden_units_node: list or tuple of neuron counts in the hidden layers used in the MLP for processing
    node features
    :param hidden_units_edge: list or tuple of neuron counts in the hidden layers used in the MLP for processing
    edge features
    :param dropout_rate: The dropout rate used after each dense layer in the node- or edge-MLPs
    :param use_bias: Whether to use bias in the hidden layers in the node- and edge-MLPs
    :param activation: Activation function to be used within the layer
    :param weight_initializer: Weight initializer to be used within the layer
    :param weight_regularizer: Weight regularizer to be used within the layer
    :param bias_initializer: Bias initializer to be used within the layer
    """
    super(GraphConvolutionGRU, self).__init__(
        adjacency_matrix=adjacency_matrix,
        embedding_size=embedding_size,
        hidden_units_node=hidden_units_node,
        hidden_units_edge=hidden_units_edge,
        dropout_rate=dropout_rate,
        use_bias=use_bias,
        activation=activation,
        weight_initializer=weight_initializer,
        weight_regularizer=weight_regularizer,
        bias_initializer=bias_initializer,
    )

GraphConvolutionLSTM #

Bases: GraphLSTM

Implementation of a GraphLSTM layer using a GraphConvolution layer as graph layer. See the documentation on how temporal layers work.

Source code in graphs_on_grids/layers/temporal/conv.py
class GraphConvolutionLSTM(GraphLSTM):
    """
    Implementation of a `GraphLSTM` layer using a `GraphConvolution` layer as graph layer.
    See the [documentation](/usage/temporal_layers) on how temporal layers work.
    """

    def __init__(
        self,
        adjacency_matrix: np.ndarray,
        embedding_size: int,
        hidden_units_node: list | tuple = None,
        hidden_units_edge: list | tuple = None,
        dropout_rate: int | float = 0,
        use_bias: bool = True,
        activation: str | None = None,
        weight_initializer: str
        | keras.initializers.Initializer
        | None = "glorot_uniform",
        weight_regularizer: str | keras.regularizers.Regularizer | None = None,
        bias_initializer: str | keras.initializers.Initializer | None = "zeros",
    ):
        """
        :param adjacency_matrix: adjacency matrix of the graphs to be passed to the model
        :param embedding_size: the output dimensionality of the node feature vector
        :param hidden_units_node: list or tuple of neuron counts in the hidden layers used in the MLP for processing
        node features
        :param hidden_units_edge: list or tuple of neuron counts in the hidden layers used in the MLP for processing
        edge features
        :param dropout_rate: The dropout rate used after each dense layer in the node- or edge-MLPs
        :param use_bias: Whether to use bias in the hidden layers in the node- and edge-MLPs
        :param activation: Activation function to be used within the layer
        :param weight_initializer: Weight initializer to be used within the layer
        :param weight_regularizer: Weight regularizer to be used within the layer
        :param bias_initializer: Bias initializer to be used within the layer
        """
        super(GraphConvolutionLSTM, self).__init__(
            adjacency_matrix=adjacency_matrix,
            embedding_size=embedding_size,
            hidden_units_node=hidden_units_node,
            hidden_units_edge=hidden_units_edge,
            dropout_rate=dropout_rate,
            use_bias=use_bias,
            activation=activation,
            weight_initializer=weight_initializer,
            weight_regularizer=weight_regularizer,
            bias_initializer=bias_initializer,
        )

    def build(self, input_shape):
        super().build(input_shape)
        self.graph_layer = GraphConvolution(
            adjacency_matrix=self.adjacency_matrix,
            embedding_size=self.embedding_size,
            hidden_units_node=self.hidden_units_node,
            hidden_units_edge=self.hidden_units_edge,
            dropout_rate=self.dropout_rate,
            use_bias=self.use_bias,
            activation=self.activation,
            weight_initializer=self.weight_initializer,
            weight_regularizer=self.weight_regularizer,
            bias_initializer=self.bias_initializer,
        )

__init__(adjacency_matrix, embedding_size, hidden_units_node=None, hidden_units_edge=None, dropout_rate=0, use_bias=True, activation=None, weight_initializer='glorot_uniform', weight_regularizer=None, bias_initializer='zeros') #

Parameters:

Name Type Description Default
adjacency_matrix ndarray

adjacency matrix of the graphs to be passed to the model

required
embedding_size int

the output dimensionality of the node feature vector

required
hidden_units_node list | tuple

list or tuple of neuron counts in the hidden layers used in the MLP for processing node features

None
hidden_units_edge list | tuple

list or tuple of neuron counts in the hidden layers used in the MLP for processing edge features

None
dropout_rate int | float

The dropout rate used after each dense layer in the node- or edge-MLPs

0
use_bias bool

Whether to use bias in the hidden layers in the node- and edge-MLPs

True
activation str | None

Activation function to be used within the layer

None
weight_initializer str | Initializer | None

Weight initializer to be used within the layer

'glorot_uniform'
weight_regularizer str | Regularizer | None

Weight regularizer to be used within the layer

None
bias_initializer str | Initializer | None

Bias initializer to be used within the layer

'zeros'
Source code in graphs_on_grids/layers/temporal/conv.py
def __init__(
    self,
    adjacency_matrix: np.ndarray,
    embedding_size: int,
    hidden_units_node: list | tuple = None,
    hidden_units_edge: list | tuple = None,
    dropout_rate: int | float = 0,
    use_bias: bool = True,
    activation: str | None = None,
    weight_initializer: str
    | keras.initializers.Initializer
    | None = "glorot_uniform",
    weight_regularizer: str | keras.regularizers.Regularizer | None = None,
    bias_initializer: str | keras.initializers.Initializer | None = "zeros",
):
    """
    :param adjacency_matrix: adjacency matrix of the graphs to be passed to the model
    :param embedding_size: the output dimensionality of the node feature vector
    :param hidden_units_node: list or tuple of neuron counts in the hidden layers used in the MLP for processing
    node features
    :param hidden_units_edge: list or tuple of neuron counts in the hidden layers used in the MLP for processing
    edge features
    :param dropout_rate: The dropout rate used after each dense layer in the node- or edge-MLPs
    :param use_bias: Whether to use bias in the hidden layers in the node- and edge-MLPs
    :param activation: Activation function to be used within the layer
    :param weight_initializer: Weight initializer to be used within the layer
    :param weight_regularizer: Weight regularizer to be used within the layer
    :param bias_initializer: Bias initializer to be used within the layer
    """
    super(GraphConvolutionLSTM, self).__init__(
        adjacency_matrix=adjacency_matrix,
        embedding_size=embedding_size,
        hidden_units_node=hidden_units_node,
        hidden_units_edge=hidden_units_edge,
        dropout_rate=dropout_rate,
        use_bias=use_bias,
        activation=activation,
        weight_initializer=weight_initializer,
        weight_regularizer=weight_regularizer,
        bias_initializer=bias_initializer,
    )

graphs_on_grids.layers.temporal.attention #

GraphAttentionConvLSTM #

Bases: GraphConvLSTM

Implementation of a GraphConvLSTM layer using a GraphAttention layer as graph layer. See the documentation on how temporal layers work.

Source code in graphs_on_grids/layers/temporal/attention.py
class GraphAttentionConvLSTM(GraphConvLSTM):
    """
    Implementation of a `GraphConvLSTM` layer using a `GraphAttention` layer as graph layer.
    See the [documentation](/usage/temporal_layers) on how temporal layers work.
    """

    def __init__(
        self,
        adjacency_matrix: np.ndarray,
        embedding_size: int,
        hidden_units_node: list | tuple = None,
        hidden_units_attention: list | tuple = None,
        dropout_rate: int | float = 0,
        use_bias: bool = True,
        activation: str | None = None,
        weight_initializer: str
        | keras.initializers.Initializer
        | None = "glorot_uniform",
        weight_regularizer: str | keras.regularizers.Regularizer | None = None,
        bias_initializer: str | keras.initializers.Initializer | None = "zeros",
    ):
        """
        :param adjacency_matrix: adjacency matrix of the graphs to be passed to the model
        :param embedding_size: the output dimensionality of the node feature vector
        :param hidden_units_node: list or tuple of neuron counts in the hidden layers used in the MLP for processing
        node features
        :param hidden_units_attention: list or tuple of neuron counts in the hidden layers used in the MLP for
        computing attention scores
        :param dropout_rate: The dropout rate used after each dense layer in the node- or edge-MLPs
        :param use_bias: Whether to use bias in the hidden layers in the node- and edge-MLPs
        :param activation: Activation function to be used within the layer
        :param weight_initializer: Weight initializer to be used within the layer
        :param weight_regularizer: Weight regularizer to be used within the layer
        :param bias_initializer: Bias initializer to be used within the layer
        """
        super(GraphAttentionConvLSTM, self).__init__(
            adjacency_matrix=adjacency_matrix,
            embedding_size=embedding_size,
            hidden_units_node=hidden_units_node,
            hidden_units_edge=hidden_units_attention,
            dropout_rate=dropout_rate,
            use_bias=use_bias,
            activation=activation,
            weight_initializer=weight_initializer,
            weight_regularizer=weight_regularizer,
            bias_initializer=bias_initializer,
        )

    def build(self, input_shape):
        super().build(input_shape)
        self.graph_layer = GraphAttention(
            adjacency_matrix=self.adjacency_matrix,
            embedding_size=self.embedding_size,
            hidden_units_node=self.hidden_units_node,
            hidden_units_attention=self.hidden_units_edge,
            dropout_rate=self.dropout_rate,
            use_bias=self.use_bias,
            activation=self.activation,
            weight_initializer=self.weight_initializer,
            weight_regularizer=self.weight_regularizer,
            bias_initializer=self.bias_initializer,
        )

__init__(adjacency_matrix, embedding_size, hidden_units_node=None, hidden_units_attention=None, dropout_rate=0, use_bias=True, activation=None, weight_initializer='glorot_uniform', weight_regularizer=None, bias_initializer='zeros') #

Parameters:

Name Type Description Default
adjacency_matrix ndarray

adjacency matrix of the graphs to be passed to the model

required
embedding_size int

the output dimensionality of the node feature vector

required
hidden_units_node list | tuple

list or tuple of neuron counts in the hidden layers used in the MLP for processing node features

None
hidden_units_attention list | tuple

list or tuple of neuron counts in the hidden layers used in the MLP for computing attention scores

None
dropout_rate int | float

The dropout rate used after each dense layer in the node- or edge-MLPs

0
use_bias bool

Whether to use bias in the hidden layers in the node- and edge-MLPs

True
activation str | None

Activation function to be used within the layer

None
weight_initializer str | Initializer | None

Weight initializer to be used within the layer

'glorot_uniform'
weight_regularizer str | Regularizer | None

Weight regularizer to be used within the layer

None
bias_initializer str | Initializer | None

Bias initializer to be used within the layer

'zeros'
Source code in graphs_on_grids/layers/temporal/attention.py
def __init__(
    self,
    adjacency_matrix: np.ndarray,
    embedding_size: int,
    hidden_units_node: list | tuple = None,
    hidden_units_attention: list | tuple = None,
    dropout_rate: int | float = 0,
    use_bias: bool = True,
    activation: str | None = None,
    weight_initializer: str
    | keras.initializers.Initializer
    | None = "glorot_uniform",
    weight_regularizer: str | keras.regularizers.Regularizer | None = None,
    bias_initializer: str | keras.initializers.Initializer | None = "zeros",
):
    """
    :param adjacency_matrix: adjacency matrix of the graphs to be passed to the model
    :param embedding_size: the output dimensionality of the node feature vector
    :param hidden_units_node: list or tuple of neuron counts in the hidden layers used in the MLP for processing
    node features
    :param hidden_units_attention: list or tuple of neuron counts in the hidden layers used in the MLP for
    computing attention scores
    :param dropout_rate: The dropout rate used after each dense layer in the node- or edge-MLPs
    :param use_bias: Whether to use bias in the hidden layers in the node- and edge-MLPs
    :param activation: Activation function to be used within the layer
    :param weight_initializer: Weight initializer to be used within the layer
    :param weight_regularizer: Weight regularizer to be used within the layer
    :param bias_initializer: Bias initializer to be used within the layer
    """
    super(GraphAttentionConvLSTM, self).__init__(
        adjacency_matrix=adjacency_matrix,
        embedding_size=embedding_size,
        hidden_units_node=hidden_units_node,
        hidden_units_edge=hidden_units_attention,
        dropout_rate=dropout_rate,
        use_bias=use_bias,
        activation=activation,
        weight_initializer=weight_initializer,
        weight_regularizer=weight_regularizer,
        bias_initializer=bias_initializer,
    )

GraphAttentionGRU #

Bases: GraphGRU

Implementation of a GraphGRU layer using a GraphAttention layer as graph layer. See the documentation on how temporal layers work.

Source code in graphs_on_grids/layers/temporal/attention.py
class GraphAttentionGRU(GraphGRU):
    """
    Implementation of a `GraphGRU` layer using a `GraphAttention` layer as graph layer.
    See the [documentation](/usage/temporal_layers) on how temporal layers work.
    """

    def __init__(
        self,
        adjacency_matrix: np.ndarray,
        embedding_size: int,
        hidden_units_node: list | tuple = None,
        hidden_units_attention: list | tuple = None,
        dropout_rate: int | float = 0,
        use_bias: bool = True,
        activation: str | None = None,
        weight_initializer: str
        | keras.initializers.Initializer
        | None = "glorot_uniform",
        weight_regularizer: str | keras.regularizers.Regularizer | None = None,
        bias_initializer: str | keras.initializers.Initializer | None = "zeros",
    ):
        """
        :param adjacency_matrix: adjacency matrix of the graphs to be passed to the model
        :param embedding_size: the output dimensionality of the node feature vector
        :param hidden_units_node: list or tuple of neuron counts in the hidden layers used in the MLP for processing
        node features
        :param hidden_units_attention: list or tuple of neuron counts in the hidden layers used in the MLP for
        computing attention scores
        :param dropout_rate: The dropout rate used after each dense layer in the node- or edge-MLPs
        :param use_bias: Whether to use bias in the hidden layers in the node- and edge-MLPs
        :param activation: Activation function to be used within the layer
        :param weight_initializer: Weight initializer to be used within the layer
        :param weight_regularizer: Weight regularizer to be used within the layer
        :param bias_initializer: Bias initializer to be used within the layer
        """
        super(GraphAttentionGRU, self).__init__(
            adjacency_matrix=adjacency_matrix,
            embedding_size=embedding_size,
            hidden_units_node=hidden_units_node,
            hidden_units_edge=hidden_units_attention,
            dropout_rate=dropout_rate,
            use_bias=use_bias,
            activation=activation,
            weight_initializer=weight_initializer,
            weight_regularizer=weight_regularizer,
            bias_initializer=bias_initializer,
        )

    def build(self, input_shape):
        super().build(input_shape)
        self.graph_layer = GraphAttention(
            adjacency_matrix=self.adjacency_matrix,
            embedding_size=self.embedding_size,
            hidden_units_node=self.hidden_units_node,
            hidden_units_attention=self.hidden_units_edge,
            dropout_rate=self.dropout_rate,
            use_bias=self.use_bias,
            activation=self.activation,
            weight_initializer=self.weight_initializer,
            weight_regularizer=self.weight_regularizer,
            bias_initializer=self.bias_initializer,
        )

__init__(adjacency_matrix, embedding_size, hidden_units_node=None, hidden_units_attention=None, dropout_rate=0, use_bias=True, activation=None, weight_initializer='glorot_uniform', weight_regularizer=None, bias_initializer='zeros') #

Parameters:

Name Type Description Default
adjacency_matrix ndarray

adjacency matrix of the graphs to be passed to the model

required
embedding_size int

the output dimensionality of the node feature vector

required
hidden_units_node list | tuple

list or tuple of neuron counts in the hidden layers used in the MLP for processing node features

None
hidden_units_attention list | tuple

list or tuple of neuron counts in the hidden layers used in the MLP for computing attention scores

None
dropout_rate int | float

The dropout rate used after each dense layer in the node- or edge-MLPs

0
use_bias bool

Whether to use bias in the hidden layers in the node- and edge-MLPs

True
activation str | None

Activation function to be used within the layer

None
weight_initializer str | Initializer | None

Weight initializer to be used within the layer

'glorot_uniform'
weight_regularizer str | Regularizer | None

Weight regularizer to be used within the layer

None
bias_initializer str | Initializer | None

Bias initializer to be used within the layer

'zeros'
Source code in graphs_on_grids/layers/temporal/attention.py
def __init__(
    self,
    adjacency_matrix: np.ndarray,
    embedding_size: int,
    hidden_units_node: list | tuple = None,
    hidden_units_attention: list | tuple = None,
    dropout_rate: int | float = 0,
    use_bias: bool = True,
    activation: str | None = None,
    weight_initializer: str
    | keras.initializers.Initializer
    | None = "glorot_uniform",
    weight_regularizer: str | keras.regularizers.Regularizer | None = None,
    bias_initializer: str | keras.initializers.Initializer | None = "zeros",
):
    """
    :param adjacency_matrix: adjacency matrix of the graphs to be passed to the model
    :param embedding_size: the output dimensionality of the node feature vector
    :param hidden_units_node: list or tuple of neuron counts in the hidden layers used in the MLP for processing
    node features
    :param hidden_units_attention: list or tuple of neuron counts in the hidden layers used in the MLP for
    computing attention scores
    :param dropout_rate: The dropout rate used after each dense layer in the node- or edge-MLPs
    :param use_bias: Whether to use bias in the hidden layers in the node- and edge-MLPs
    :param activation: Activation function to be used within the layer
    :param weight_initializer: Weight initializer to be used within the layer
    :param weight_regularizer: Weight regularizer to be used within the layer
    :param bias_initializer: Bias initializer to be used within the layer
    """
    super(GraphAttentionGRU, self).__init__(
        adjacency_matrix=adjacency_matrix,
        embedding_size=embedding_size,
        hidden_units_node=hidden_units_node,
        hidden_units_edge=hidden_units_attention,
        dropout_rate=dropout_rate,
        use_bias=use_bias,
        activation=activation,
        weight_initializer=weight_initializer,
        weight_regularizer=weight_regularizer,
        bias_initializer=bias_initializer,
    )

GraphAttentionLSTM #

Bases: GraphLSTM

Implementation of a GraphLSTM layer using a GraphAttention layer as graph layer. See the documentation on how temporal layers work.

Source code in graphs_on_grids/layers/temporal/attention.py
class GraphAttentionLSTM(GraphLSTM):
    """
    Implementation of a `GraphLSTM` layer using a `GraphAttention` layer as graph layer.
    See the [documentation](/usage/temporal_layers) on how temporal layers work.
    """

    def __init__(
        self,
        adjacency_matrix: np.ndarray,
        embedding_size: int,
        hidden_units_node: list | tuple = None,
        hidden_units_attention: list | tuple = None,
        dropout_rate: int | float = 0,
        use_bias: bool = True,
        activation: str | None = None,
        weight_initializer: str
        | keras.initializers.Initializer
        | None = "glorot_uniform",
        weight_regularizer: str | keras.regularizers.Regularizer | None = None,
        bias_initializer: str | keras.initializers.Initializer | None = "zeros",
    ):
        """
        :param adjacency_matrix: adjacency matrix of the graphs to be passed to the model
        :param embedding_size: the output dimensionality of the node feature vector
        :param hidden_units_node: list or tuple of neuron counts in the hidden layers used in the MLP for processing
        node features
        :param hidden_units_attention: list or tuple of neuron counts in the hidden layers used in the MLP for
        computing attention scores
        :param dropout_rate: The dropout rate used after each dense layer in the node- or edge-MLPs
        :param use_bias: Whether to use bias in the hidden layers in the node- and edge-MLPs
        :param activation: Activation function to be used within the layer
        :param weight_initializer: Weight initializer to be used within the layer
        :param weight_regularizer: Weight regularizer to be used within the layer
        :param bias_initializer: Bias initializer to be used within the layer
        """
        super(GraphAttentionLSTM, self).__init__(
            adjacency_matrix=adjacency_matrix,
            embedding_size=embedding_size,
            hidden_units_node=hidden_units_node,
            hidden_units_edge=hidden_units_attention,
            dropout_rate=dropout_rate,
            use_bias=use_bias,
            activation=activation,
            weight_initializer=weight_initializer,
            weight_regularizer=weight_regularizer,
            bias_initializer=bias_initializer,
        )

    def build(self, input_shape):
        super().build(input_shape)
        self.graph_layer = GraphAttention(
            adjacency_matrix=self.adjacency_matrix,
            embedding_size=self.embedding_size,
            hidden_units_node=self.hidden_units_node,
            hidden_units_attention=self.hidden_units_edge,
            dropout_rate=self.dropout_rate,
            use_bias=self.use_bias,
            activation=self.activation,
            weight_initializer=self.weight_initializer,
            weight_regularizer=self.weight_regularizer,
            bias_initializer=self.bias_initializer,
        )

__init__(adjacency_matrix, embedding_size, hidden_units_node=None, hidden_units_attention=None, dropout_rate=0, use_bias=True, activation=None, weight_initializer='glorot_uniform', weight_regularizer=None, bias_initializer='zeros') #

Parameters:

Name Type Description Default
adjacency_matrix ndarray

adjacency matrix of the graphs to be passed to the model

required
embedding_size int

the output dimensionality of the node feature vector

required
hidden_units_node list | tuple

list or tuple of neuron counts in the hidden layers used in the MLP for processing node features

None
hidden_units_attention list | tuple

list or tuple of neuron counts in the hidden layers used in the MLP for computing attention scores

None
dropout_rate int | float

The dropout rate used after each dense layer in the node- or edge-MLPs

0
use_bias bool

Whether to use bias in the hidden layers in the node- and edge-MLPs

True
activation str | None

Activation function to be used within the layer

None
weight_initializer str | Initializer | None

Weight initializer to be used within the layer

'glorot_uniform'
weight_regularizer str | Regularizer | None

Weight regularizer to be used within the layer

None
bias_initializer str | Initializer | None

Bias initializer to be used within the layer

'zeros'
Source code in graphs_on_grids/layers/temporal/attention.py
def __init__(
    self,
    adjacency_matrix: np.ndarray,
    embedding_size: int,
    hidden_units_node: list | tuple = None,
    hidden_units_attention: list | tuple = None,
    dropout_rate: int | float = 0,
    use_bias: bool = True,
    activation: str | None = None,
    weight_initializer: str
    | keras.initializers.Initializer
    | None = "glorot_uniform",
    weight_regularizer: str | keras.regularizers.Regularizer | None = None,
    bias_initializer: str | keras.initializers.Initializer | None = "zeros",
):
    """
    :param adjacency_matrix: adjacency matrix of the graphs to be passed to the model
    :param embedding_size: the output dimensionality of the node feature vector
    :param hidden_units_node: list or tuple of neuron counts in the hidden layers used in the MLP for processing
    node features
    :param hidden_units_attention: list or tuple of neuron counts in the hidden layers used in the MLP for
    computing attention scores
    :param dropout_rate: The dropout rate used after each dense layer in the node- or edge-MLPs
    :param use_bias: Whether to use bias in the hidden layers in the node- and edge-MLPs
    :param activation: Activation function to be used within the layer
    :param weight_initializer: Weight initializer to be used within the layer
    :param weight_regularizer: Weight regularizer to be used within the layer
    :param bias_initializer: Bias initializer to be used within the layer
    """
    super(GraphAttentionLSTM, self).__init__(
        adjacency_matrix=adjacency_matrix,
        embedding_size=embedding_size,
        hidden_units_node=hidden_units_node,
        hidden_units_edge=hidden_units_attention,
        dropout_rate=dropout_rate,
        use_bias=use_bias,
        activation=activation,
        weight_initializer=weight_initializer,
        weight_regularizer=weight_regularizer,
        bias_initializer=bias_initializer,
    )

GraphAttentionTemporalConv #

Bases: TemporalConv

Implementation of a TemporalConv layer using a GraphAttention layer as graph layer. See the documentation on how temporal layers work.

Source code in graphs_on_grids/layers/temporal/attention.py
class GraphAttentionTemporalConv(TemporalConv):
    """
    Implementation of a `TemporalConv` layer using a `GraphAttention` layer as graph layer.
    See the [documentation](/usage/temporal_layers) on how temporal layers work.
    """

    def __init__(
        self,
        adjacency_matrix: np.ndarray,
        embedding_size: int,
        output_seq_len: int,
        hidden_units_node: list | tuple = None,
        hidden_units_attention: list | tuple = None,
        dropout_rate: int | float = 0,
        use_bias: bool = True,
        activation: str | None = None,
        weight_initializer: str
        | keras.initializers.Initializer
        | None = "glorot_uniform",
        weight_regularizer: str | keras.regularizers.Regularizer | None = None,
        bias_initializer: str | keras.initializers.Initializer | None = "zeros",
    ):
        """
        :param adjacency_matrix: adjacency matrix of the graphs to be passed to the model
        :param embedding_size: the output dimensionality of the node feature vector
        :param output_seq_len: number of graphs in the output sequence
        :param hidden_units_node: list or tuple of neuron counts in the hidden layers used in the MLP for processing
        node features
        :param hidden_units_attention: list or tuple of neuron counts in the hidden layers used in the MLP for
        computing attention scores
        :param dropout_rate: The dropout rate used after each dense layer in the node- or edge-MLPs
        :param use_bias: Whether to use bias in the hidden layers in the node- and edge-MLPs
        :param activation: Activation function to be used within the layer
        :param weight_initializer: Weight initializer to be used within the layer
        :param weight_regularizer: Weight regularizer to be used within the layer
        :param bias_initializer: Bias initializer to be used within the layer
        """
        super(GraphAttentionTemporalConv, self).__init__(
            adjacency_matrix=adjacency_matrix,
            embedding_size=embedding_size,
            output_seq_len=output_seq_len,
            hidden_units_node=hidden_units_node,
            hidden_units_edge=hidden_units_attention,
            dropout_rate=dropout_rate,
            use_bias=use_bias,
            activation=activation,
            weight_initializer=weight_initializer,
            weight_regularizer=weight_regularizer,
            bias_initializer=bias_initializer,
        )

    def build(self, input_shape):
        super().build(input_shape=input_shape)
        self.graph_layer = GraphAttention(
            adjacency_matrix=self.adjacency_matrix,
            embedding_size=self.embedding_size,
            hidden_units_node=self.hidden_units_node,
            hidden_units_attention=self.hidden_units_edge,
            dropout_rate=self.dropout_rate,
            use_bias=self.use_bias,
            activation=self.activation,
            weight_initializer=self.weight_initializer,
            weight_regularizer=self.weight_regularizer,
            bias_initializer=self.bias_initializer,
        )

__init__(adjacency_matrix, embedding_size, output_seq_len, hidden_units_node=None, hidden_units_attention=None, dropout_rate=0, use_bias=True, activation=None, weight_initializer='glorot_uniform', weight_regularizer=None, bias_initializer='zeros') #

Parameters:

Name Type Description Default
adjacency_matrix ndarray

adjacency matrix of the graphs to be passed to the model

required
embedding_size int

the output dimensionality of the node feature vector

required
output_seq_len int

number of graphs in the output sequence

required
hidden_units_node list | tuple

list or tuple of neuron counts in the hidden layers used in the MLP for processing node features

None
hidden_units_attention list | tuple

list or tuple of neuron counts in the hidden layers used in the MLP for computing attention scores

None
dropout_rate int | float

The dropout rate used after each dense layer in the node- or edge-MLPs

0
use_bias bool

Whether to use bias in the hidden layers in the node- and edge-MLPs

True
activation str | None

Activation function to be used within the layer

None
weight_initializer str | Initializer | None

Weight initializer to be used within the layer

'glorot_uniform'
weight_regularizer str | Regularizer | None

Weight regularizer to be used within the layer

None
bias_initializer str | Initializer | None

Bias initializer to be used within the layer

'zeros'
Source code in graphs_on_grids/layers/temporal/attention.py
def __init__(
    self,
    adjacency_matrix: np.ndarray,
    embedding_size: int,
    output_seq_len: int,
    hidden_units_node: list | tuple = None,
    hidden_units_attention: list | tuple = None,
    dropout_rate: int | float = 0,
    use_bias: bool = True,
    activation: str | None = None,
    weight_initializer: str
    | keras.initializers.Initializer
    | None = "glorot_uniform",
    weight_regularizer: str | keras.regularizers.Regularizer | None = None,
    bias_initializer: str | keras.initializers.Initializer | None = "zeros",
):
    """
    :param adjacency_matrix: adjacency matrix of the graphs to be passed to the model
    :param embedding_size: the output dimensionality of the node feature vector
    :param output_seq_len: number of graphs in the output sequence
    :param hidden_units_node: list or tuple of neuron counts in the hidden layers used in the MLP for processing
    node features
    :param hidden_units_attention: list or tuple of neuron counts in the hidden layers used in the MLP for
    computing attention scores
    :param dropout_rate: The dropout rate used after each dense layer in the node- or edge-MLPs
    :param use_bias: Whether to use bias in the hidden layers in the node- and edge-MLPs
    :param activation: Activation function to be used within the layer
    :param weight_initializer: Weight initializer to be used within the layer
    :param weight_regularizer: Weight regularizer to be used within the layer
    :param bias_initializer: Bias initializer to be used within the layer
    """
    super(GraphAttentionTemporalConv, self).__init__(
        adjacency_matrix=adjacency_matrix,
        embedding_size=embedding_size,
        output_seq_len=output_seq_len,
        hidden_units_node=hidden_units_node,
        hidden_units_edge=hidden_units_attention,
        dropout_rate=dropout_rate,
        use_bias=use_bias,
        activation=activation,
        weight_initializer=weight_initializer,
        weight_regularizer=weight_regularizer,
        bias_initializer=bias_initializer,
    )

graphs_on_grids.layers.temporal.output_layer #

ConvOutputBlock #

Bases: Layer

Convolutional output layer to be used with implementations of the TemporalConv layers. A 2D-Convolution is applied to create graphs according to the parameter output_seq_len. At the output, a dense layer adjusts the graphs to the embedding size given by the units parameter.

Source code in graphs_on_grids/layers/temporal/output_layer.py
class ConvOutputBlock(keras.layers.Layer):
    """
    Convolutional output layer to be used with implementations of the `TemporalConv` layers.
    A 2D-Convolution is applied to create graphs according to the parameter `output_seq_len`. At the output,
    a dense layer adjusts the graphs to the embedding size given by the `units` parameter.
    """

    def __init__(self, output_seq_len: int, units: int, activation: str = None) -> None:
        """
        :param output_seq_len: number of graphs in the output sequence
        :param units: embedding size of the output graph(s)
        :param activation: activation function of the dense output layer
        """
        super(ConvOutputBlock, self).__init__()
        self.output_seq_len = output_seq_len
        self.units = units
        self.activation = keras.activations.get(activation)

    def build(self, input_shape):
        batch_size, seq_len, num_nodes, num_features = input_shape
        self.output_conv = keras.layers.Conv2D(
            filters=self.output_seq_len,
            kernel_size=(1, num_features),
            padding="same",
            activation="relu",
        )
        self.dense = keras.layers.Dense(units=self.units, activation=self.activation)

    def call(self, inputs, *args, **kwargs):
        inputs = tf.transpose(inputs, perm=[0, 2, 3, 1])
        output_conv = self.output_conv(inputs)
        output_conv_transposed = tf.transpose(output_conv, perm=[0, 3, 1, 2])
        output = self.dense(output_conv_transposed)
        return output

    def get_config(self):
        config = super().get_config()
        config.update(
            {
                "output_seq_len": self.output_seq_len,
                "units": self.units,
                "activation": keras.activations.serialize(self.activation),
            }
        )
        return config

__init__(output_seq_len, units, activation=None) #

Parameters:

Name Type Description Default
output_seq_len int

number of graphs in the output sequence

required
units int

embedding size of the output graph(s)

required
activation str

activation function of the dense output layer

None
Source code in graphs_on_grids/layers/temporal/output_layer.py
def __init__(self, output_seq_len: int, units: int, activation: str = None) -> None:
    """
    :param output_seq_len: number of graphs in the output sequence
    :param units: embedding size of the output graph(s)
    :param activation: activation function of the dense output layer
    """
    super(ConvOutputBlock, self).__init__()
    self.output_seq_len = output_seq_len
    self.units = units
    self.activation = keras.activations.get(activation)

RecurrentOutputBlock #

Bases: Layer

Recurrent output layer to be used with implementations of the GraphLSTM, GraphGRU and GraphConvLSTM layers. The last output of the last temporal layer is taken and passed through a dense layer with units * output_seq_len neurons. The output is then reshaped to generate output_seq_len graphs with embedding size units.

Source code in graphs_on_grids/layers/temporal/output_layer.py
class RecurrentOutputBlock(keras.layers.Layer):
    """
    Recurrent output layer to be used with implementations of the `GraphLSTM`, `GraphGRU` and `GraphConvLSTM` layers.
    The last output of the last temporal layer is taken and passed through a dense layer with `units` * `output_seq_len`
    neurons. The output is then reshaped to generate `output_seq_len` graphs with embedding size `units`.
    """

    def __init__(self, output_seq_len: int, units: int, activation: str = None) -> None:
        """
        :param output_seq_len: number of graphs in the output sequence
        :param units: embedding size of the output graph(s)
        :param activation: activation function of the dense output layer
        """
        super(RecurrentOutputBlock, self).__init__()
        self.output_seq_len = output_seq_len
        self.units = units
        self.activation = keras.activations.get(activation)

    def build(self, input_shape):
        self.out_dense = keras.layers.Dense(
            units=self.units * self.output_seq_len, activation=self.activation
        )

    def call(self, inputs, *args, **kwargs):
        # input: (batch_size, seq_len, num_nodes, num_features)
        shape = tf.shape(inputs)
        batch_size, seq_len, num_nodes, num_features = (
            shape[0],
            shape[1],
            shape[2],
            shape[3],
        )
        # take last output in LSTM-sequence
        last_lstm_output = inputs[:, -1, :, :]

        # create #output_seq_len new graphs from lstm prediction
        dense_out = self.out_dense(last_lstm_output)
        dense_out = tf.expand_dims(dense_out, axis=1)

        # reshape to (batch_size, output_seq_len, num_nodes, num_features)
        reshape = tf.reshape(
            dense_out, (batch_size, self.output_seq_len, num_nodes, self.units)
        )
        return reshape

    def get_config(self):
        config = super().get_config()
        config.update(
            {
                "output_seq_len": self.output_seq_len,
                "units": self.units,
                "activation": keras.activations.serialize(self.activation),
            }
        )
        return config

__init__(output_seq_len, units, activation=None) #

Parameters:

Name Type Description Default
output_seq_len int

number of graphs in the output sequence

required
units int

embedding size of the output graph(s)

required
activation str

activation function of the dense output layer

None
Source code in graphs_on_grids/layers/temporal/output_layer.py
def __init__(self, output_seq_len: int, units: int, activation: str = None) -> None:
    """
    :param output_seq_len: number of graphs in the output sequence
    :param units: embedding size of the output graph(s)
    :param activation: activation function of the dense output layer
    """
    super(RecurrentOutputBlock, self).__init__()
    self.output_seq_len = output_seq_len
    self.units = units
    self.activation = keras.activations.get(activation)