graphinvent/GraphGenerator.py
def initialize_graph_batch(self) -> None:
        """
        Initializes a batch of empty graphs (zero `torch.Tensor`s) to begin the
        generation process. Creates the following:
            self.nodes (torch.Tensor)   : Empty node features tensor (batch).
            self.edges (torch.Tensor)   : Empty edge features tensor (batch).
            self.n_nodes (torch.Tensor) : Number of nodes per graph in (batch),
                                          currently all 0.

        Also, creates a dummy "non-empty" graph at index 0, so that the models
        do not freak out when they receive entirely zero torch tensors as input
        (haven't found a more elegant solution to this problem; without the
        dummy non-empty graph, there is a silent error in the message update
        function of the MPNNs).
        """
        # define tensor shapes
        node_shape = ([self.batch_size] + constants.dim_nodes)
        edge_shape = ([self.batch_size] + constants.dim_edges)
        n_nodes_shape = [self.batch_size]

        # initialize tensors
        self.nodes = torch.zeros(node_shape,
                                 dtype=torch.float32,
                                 device=constants.device)
        self.edges = torch.zeros(edge_shape,
                                 dtype=torch.float32,
                                 device=constants.device)
        self.n_nodes = torch.zeros(n_nodes_shape,
                                   dtype=torch.int8,
                                   device=constants.device)

        # add a dummy non-empty graph at idx 0, since models cannot receive
        # purely empty graphs
        self.nodes[0] = torch.ones(([1] + constants.dim_nodes),
                                   device=constants.device)
        self.edges[0, 0, 0, 0] = 1
        self.n_nodes[0] = 1

        Initializes a batch of empty graphs (zero `torch.Tensor`s) to begin the
        generation process. Creates the following:
            self.nodes (torch.Tensor)   : Empty node features tensor (batch).
            self.edges (torch.Tensor)   : Empty edge features tensor (batch).
            self.n_nodes (torch.Tensor) : Number of nodes per graph in (batch),
                                          currently all 0.

        Also, creates a dummy "non-empty" graph at index 0, so that the models
        do not freak out when they receive entirely zero torch tensors as input
        (haven't found a more elegant solution to this problem; without the
        dummy non-empty graph, there is a silent error in the message update
        function of the MPNNs).
        
Initializes a batch of empty graphs (zero `torch.Tensor`s) to begin the
generation process. Creates the following:
self.nodes (torch.Tensor)   : Empty node features tensor (batch).

Also, creates a dummy "non-empty" graph at index 0, so that the models
do not freak out when they receive entirely zero torch tensors as input
(haven't found a more elegant solution to this problem; without the
dummy non-empty graph, there is a silent error in the message update
function of the MPNNs).
Initializes a batch of empty graphs ( zero ` torch . Tensor ` s ) to begin the generation process . Creates the following : self . nodes ( torch . Tensor ) : Empty node features tensor ( batch ) . Also creates a dummy " non - empty " graph at index 0 so that the models do not freak out when they receive entirely zero torch tensors as input ( haven ' t found a more elegant solution to this problem ; without the dummy non - empty graph there is a silent error in the message update function of the MPNNs ) .
def initialize_graph_batch(self) -> None:
        node_shape = ([self.batch_size] + constants.dim_nodes)
        edge_shape = ([self.batch_size] + constants.dim_edges)
        n_nodes_shape = [self.batch_size]
        self.nodes = torch.zeros(node_shape,
                                 dtype=torch.float32,
                                 device=constants.device)
        self.edges = torch.zeros(edge_shape,
                                 dtype=torch.float32,
                                 device=constants.device)
        self.n_nodes = torch.zeros(n_nodes_shape,
                                   dtype=torch.int8,
                                   device=constants.device)
        self.nodes[0] = torch.ones(([1] + constants.dim_nodes),
                                   device=constants.device)
        self.edges[0, 0, 0, 0] = 1
        self.n_nodes[0] = 1
def initialize_graph_batch ( self ) -> None : node_shape = ( [ self . batch_size ] + constants . dim_nodes ) edge_shape = ( [ self . batch_size ] + constants . dim_edges ) n_nodes_shape = [ self . batch_size ] self . nodes = torch . zeros ( node_shape , dtype = torch . float32 , device = constants . device ) self . edges = torch . zeros ( edge_shape , dtype = torch . float32 , device = constants . device ) self . n_nodes = torch . zeros ( n_nodes_shape , dtype = torch . int8 , device = constants . device ) self . nodes [ 0 ] = torch . ones ( ( [ 1 ] + constants . dim_nodes ) , device = constants . device ) self . edges [ 0 , 0 , 0 , 0 ] = 1 self . n_nodes [ 0 ] = 1
Initializes a batch of empty graphs (zero `torch.Tensor`s) to begin the
generation process.
Initializes a batch of empty graphs ( zero ` torch . Tensor ` s ) to begin the generation process .
"""
        Initializes a batch of empty graphs (zero `torch.Tensor`s) to begin the
        generation process. Creates the following:
            self.nodes (torch.Tensor)   : Empty node features tensor (batch).
            self.edges (torch.Tensor)   : Empty edge features tensor (batch).
            self.n_nodes (torch.Tensor) : Number of nodes per graph in (batch),
                                          currently all 0.

        Also, creates a dummy "non-empty" graph at index 0, so that the models
        do not freak out when they receive entirely zero torch tensors as input
        (haven't found a more elegant solution to this problem; without the
        dummy non-empty graph, there is a silent error in the message update
        function of the MPNNs).
        """ # define tensor shapes # initialize tensors # add a dummy non-empty graph at idx 0, since models cannot receive # purely empty graphs
self