class_docstr: GCN_LSTM is a univariate timeseries forecasting method. The architecture  comprises of a stack of N1 Graph Convolutional layers followed by N2 LSTM layers, a Dropout layer, and  a Dense layer.
  This main components of GNN architecture is inspired by: T-GCN: A Temporal Graph Convolutional Network for Traffic Prediction (https://arxiv.org/abs/1811.05320).
  The implementation of the above paper is based on one graph convolution layer stacked with a GRU layer.
  
  The StellarGraph implementation is built as a stack of the following set of layers:
  
  1. User specified no. of Graph Convolutional layers
  2. User specified no. of LSTM layers
  3. 1 Dense layer
  4. 1 Dropout layer.
  
  The last two layers consistently showed better performance and regularization experimentally.
  
  .. seealso::
  
     Example using GCN_LSTM: `spatio-temporal time-series prediction <https://stellargraph.readthedocs.io/en/stable/demos/time-series/gcn-lstm-time-series.html>`__.
  
     Appropriate data generator: :class:`.SlidingFeaturesNodeGenerator`.
  
     Related model: :class:`.GCN` for graphs without time-series node features.
  
  Args:
     seq_len: No. of LSTM cells
     adj: unweighted/weighted adjacency matrix of [no.of nodes by no. of nodes dimension
     gc_layer_sizes (list of int): Output sizes of Graph Convolution  layers in the stack.
     lstm_layer_sizes (list of int): Output sizes of LSTM layers in the stack.
     generator (SlidingFeaturesNodeGenerator): A generator instance.
     bias (bool): If True, a bias vector is learnt for each layer in the GCN model.
     dropout (float): Dropout rate applied to input features of each GCN layer.
     gc_activations (list of str or func): Activations applied to each layer's output; defaults to ``['relu', ..., 'relu']``.
     lstm_activations (list of str or func): Activations applied to each layer's output; defaults to ``['tanh', ..., 'tanh']``.
     kernel_initializer (str or func, optional): The initialiser to use for the weights of each layer.
     kernel_regularizer (str or func, optional): The regulariser to use for the weights of each layer.
     kernel_constraint (str or func, optional): The constraint to use for the weights of each layer.
     bias_initializer (str or func, optional): The initialiser to use for the bias of each layer.
     bias_regularizer (str or func, optional): The regulariser to use for the bias of each layer.
     bias_constraint (str or func, optional): The constraint to use for the bias of each layer.
   
class_docstr_tok: ["GCN_LSTM","is","a","univariate","timeseries","forecasting","method",".","The","architecture","comprises","of","a","stack","of","N1","Graph","Convolutional","layers","followed","by","N2","LSTM","layers",",","a","Dropout","layer",",","and","a","Dense","layer",".","This","main","components","of","GNN","architecture","is","inspired","by",":","T-GCN",":","A","Temporal","Graph","Convolutional","Network","for","Traffic","Prediction","(","https",":","\/\/arxiv.org\/abs\/1811.05320",")",".","The","implementation","of","the","above","paper","is","based","on","one","graph","convolution","layer","stacked","with","a","GRU","layer",".","The","StellarGraph","implementation","is","built","as","a","stack","of","the","following","set","of","layers",":","1",".","User","specified","no",".","of","Graph","Convolutional","layers","2",".","User","specified","no",".","of","LSTM","layers","3",".","1","Dense","layer","4",".","1","Dropout","layer",".","The","last","two","layers","consistently","showed","better","performance","and","regularization","experimentally",".","..","seealso",":",":","Example","using","GCN_LSTM",":","`","spatio-temporal","time-series","prediction","<","https",":","\/\/stellargraph.readthedocs.io\/en\/stable\/demos\/time-series\/gcn-lstm-time-series.html",">","`","__",".","Appropriate","data","generator",":",":","class",":","`",".SlidingFeaturesNodeGenerator","`",".","Related","model",":",":","class",":","`",".GCN","`","for","graphs","without","time-series","node","features",".","Args",":","seq_len",":","No",".","of","LSTM","cells","adj",":","unweighted\/weighted","adjacency","matrix","of","[","no.of","nodes","by","no",".","of","nodes","dimension","gc_layer_sizes","(","list","of","int",")",":","Output","sizes","of","Graph","Convolution","layers","in","the","stack",".","lstm_layer_sizes","(","list","of","int",")",":","Output","sizes","of","LSTM","layers","in","the","stack",".","generator","(","SlidingFeaturesNodeGenerator",")",":","A","generator","instance",".","bias","(","bool",")",":","If","True",",","a","bias","vector","is","learnt","for","each","layer","in","the","GCN","model",".","dropout","(","float",")",":","Dropout","rate","applied","to","input","features","of","each","GCN","layer",".","gc_activations","(","list","of","str","or","func",")",":","Activations","applied","to","each","layer","'s","output",";","defaults","to","``","[","'relu","'",",","...",",","'relu","'","]","``",".","lstm_activations","(","list","of","str","or","func",")",":","Activations","applied","to","each","layer","'s","output",";","defaults","to","``","[","'tanh","'",",","...",",","'tanh","'","]","``",".","kernel_initializer","(","str","or","func",",","optional",")",":","The","initialiser","to","use","for","the","weights","of","each","layer",".","kernel_regularizer","(","str","or","func",",","optional",")",":","The","regulariser","to","use","for","the","weights","of","each","layer",".","kernel_constraint","(","str","or","func",",","optional",")",":","The","constraint","to","use","for","the","weights","of","each","layer",".","bias_initializer","(","str","or","func",",","optional",")",":","The","initialiser","to","use","for","the","bias","of","each","layer",".","bias_regularizer","(","str","or","func",",","optional",")",":","The","regulariser","to","use","for","the","bias","of","each","layer",".","bias_constraint","(","str","or","func",",","optional",")",":","The","constraint","to","use","for","the","bias","of","each","layer","."]
code: def __init__(
      self,
      seq_len,
      adj,
      gc_layer_sizes,
      lstm_layer_sizes,
      gc_activations=None,
      generator=None,
      lstm_activations=None,
      bias=True,
      dropout=0.5,
      kernel_initializer=None,
      kernel_regularizer=None,
      kernel_constraint=None,
      bias_initializer=None,
      bias_regularizer=None,
      bias_constraint=None,
  ):
      if generator is not None:
          if not isinstance(generator, SlidingFeaturesNodeGenerator):
              raise ValueError(
                  f"generator: expected a SlidingFeaturesNodeGenerator, found {type(generator).__name__}"
              )
  
          if seq_len is not None or adj is not None:
              raise ValueError(
                  "expected only one of generator and (seq_len, adj) to be specified, found multiple"
              )
  
          adj = generator.graph.to_adjacency_matrix(
              weighted=True
          ).todense()
          seq_len = generator.window_size
          variates = generator.variates
      else:
          variates = None
  
      super(GCN_LSTM, self).__init__()
  
      n_gc_layers = len(gc_layer_sizes)
      n_lstm_layers = len(lstm_layer_sizes)
  
      self.lstm_layer_sizes = lstm_layer_sizes
      self.gc_layer_sizes = gc_layer_sizes
      self.bias = bias
      self.dropout = dropout
      self.adj = adj
      self.n_nodes = adj.shape[0]
      self.n_features = seq_len
      self.seq_len = seq_len
      self.multivariate_input = variates is not None
      self.variates = variates if self.multivariate_input else 1
      self.outputs = self.n_nodes * self.variates
  
      self.kernel_initializer = initializers.get(kernel_initializer)
      self.kernel_regularizer = regularizers.get(kernel_regularizer)
      self.kernel_constraint = constraints.get(kernel_constraint)
      self.bias_initializer = initializers.get(bias_initializer)
      self.bias_regularizer = regularizers.get(bias_regularizer)
      self.bias_constraint = constraints.get(bias_constraint)
  
      # Activation function for each gcn layer
      if gc_activations is None:
          gc_activations = ["relu"] * n_gc_layers
      elif len(gc_activations) != n_gc_layers:
          raise ValueError(
              "Invalid number of activations; require one function per graph convolution layer"
          )
      self.gc_activations = gc_activations
  
      # Activation function for each lstm layer
      if lstm_activations is None:
          lstm_activations = ["tanh"] * n_lstm_layers
      elif len(lstm_activations) != n_lstm_layers:
          padding_size = n_lstm_layers - len(lstm_activations)
          if padding_size > 0:
              lstm_activations = (
                  lstm_activations + ["tanh"] * padding_size
              )
          else:
              raise ValueError(
                  "Invalid number of activations; require one function per lstm layer"
              )
      self.lstm_activations = lstm_activations
  
      self._gc_layers = [
          FixedAdjacencyGraphConvolution(
              units=self.variates * layer_size,
              A=self.adj,
              activation=activation,
              kernel_initializer=self.kernel_initializer,
              kernel_regularizer=self.kernel_regularizer,
              kernel_constraint=self.kernel_constraint,
              bias_initializer=self.bias_initializer,
              bias_regularizer=self.bias_regularizer,
              bias_constraint=self.bias_constraint,
          )
          for layer_size, activation in zip(
              self.gc_layer_sizes, self.gc_activations
          )
      ]
      self._lstm_layers = [
          LSTM(layer_size, activation=activation, return_sequences=True)
          for layer_size, activation in zip(
              self.lstm_layer_sizes[:-1], self.lstm_activations
          )
      ]
      self._lstm_layers.append(
          LSTM(
              self.lstm_layer_sizes[-1],
              activation=self.lstm_activations[-1],
              return_sequences=False,
          )
      )
      self._decoder_layer = Dense(self.outputs, activation="sigmoid")
  
file_path: stellargraph/stellargraph/layer/gcn_lstm.py
imports: import tensorflow
  from tensorflow.keras import backend
  from tensorflow.keras import activations, initializers, constraints, regularizers
  from tensorflow.keras.layers import Input, Layer, Dropout, LSTM, Dense, Permute, Reshape
  from ..mapper import SlidingFeaturesNodeGenerator
  from ..core.experimental import experimental
  from ..core.utils import calculate_laplacian
label_desc: Use image node_id 1 to create a new GCN_LSTM object  with example: obj = GCN_LSTM(seq_len, adj, gc_layer_sizes, lstm_layer_sizes, gc_activations, generator, lstm_activations, bias, dropout, kernel_initializer, kernel_regularizer, kernel_constraint, bias_initializer, bias_regularizer, bias_constraint)