graphinvent/GraphGenerator.py
def allocate_graph_tensors(self) -> None:
        """
        Allocates tensors for the node features, edge features, NLLs, and
        termination status for all graphs to be generated. These then get filled
        in during the graph generation process.
        """
        # define tensor shapes
        node_shape = (self.batch_size, *constants.dim_nodes)
        edge_shape = (self.batch_size, *constants.dim_edges)
        likelihoods_shape = (self.batch_size, constants.max_n_nodes * 2)  # the 2 is arbitrary

        # allocate a buffer equal to the size of an extra batch
        n_allocate = self.batch_size * 2

        # create the placeholder tensors:

        # placeholder for node features tensor for all graphs
        self.generated_nodes = torch.zeros((n_allocate, *node_shape[1:]),
                                           dtype=torch.float32,
                                           device=constants.device)

        # placeholder for edge features tensor for all graphs
        self.generated_edges = torch.zeros((n_allocate, *edge_shape[1:]),
                                           dtype=torch.float32,
                                           device=constants.device)

        # placeholder for number of nodes per graph in all graphs
        self.generated_n_nodes = torch.zeros(n_allocate,
                                             dtype=torch.int8,
                                             device=constants.device)


        # placeholder for sampled NLL per action for all graphs
        self.likelihoods = torch.zeros(likelihoods_shape,
                                       device=constants.device)

        # placeholder for sampled NLLs per action for all finished graphs
        self.generated_likelihoods = torch.zeros(
            (n_allocate, *likelihoods_shape[1:]),
            device=constants.device
        )

        # placeholder for graph termination status (1 == properly terminated,
        # 0 == improper)
        self.properly_terminated = torch.zeros(n_allocate,
                                               dtype=torch.int8,
                                               device=constants.device)

        Allocates tensors for the node features, edge features, NLLs, and
        termination status for all graphs to be generated. These then get filled
        in during the graph generation process.
        
Allocates tensors for the node features, edge features, NLLs, and
termination status for all graphs to be generated. These then get filled
in during the graph generation process.
Allocates tensors for the node features edge features NLLs and termination status for all graphs to be generated . These then get filled in during the graph generation process .
def allocate_graph_tensors(self) -> None:
        node_shape = (self.batch_size, *constants.dim_nodes)
        edge_shape = (self.batch_size, *constants.dim_edges)
        likelihoods_shape = (self.batch_size, constants.max_n_nodes * 2)  
        n_allocate = self.batch_size * 2
        self.generated_nodes = torch.zeros((n_allocate, *node_shape[1:]),
                                           dtype=torch.float32,
                                           device=constants.device)
        self.generated_edges = torch.zeros((n_allocate, *edge_shape[1:]),
                                           dtype=torch.float32,
                                           device=constants.device)
        self.generated_n_nodes = torch.zeros(n_allocate,
                                             dtype=torch.int8,
                                             device=constants.device)
        self.likelihoods = torch.zeros(likelihoods_shape,
                                       device=constants.device)
        self.generated_likelihoods = torch.zeros(
            (n_allocate, *likelihoods_shape[1:]),
            device=constants.device
        )
        self.properly_terminated = torch.zeros(n_allocate,
                                               dtype=torch.int8,
                                               device=constants.device)
def allocate_graph_tensors ( self ) -> None : node_shape = ( self . batch_size , * constants . dim_nodes ) edge_shape = ( self . batch_size , * constants . dim_edges ) likelihoods_shape = ( self . batch_size , constants . max_n_nodes * 2 ) n_allocate = self . batch_size * 2 self . generated_nodes = torch . zeros ( ( n_allocate , * node_shape [ 1 : ] ) , dtype = torch . float32 , device = constants . device ) self . generated_edges = torch . zeros ( ( n_allocate , * edge_shape [ 1 : ] ) , dtype = torch . float32 , device = constants . device ) self . generated_n_nodes = torch . zeros ( n_allocate , dtype = torch . int8 , device = constants . device ) self . likelihoods = torch . zeros ( likelihoods_shape , device = constants . device ) self . generated_likelihoods = torch . zeros ( ( n_allocate , * likelihoods_shape [ 1 : ] ) , device = constants . device ) self . properly_terminated = torch . zeros ( n_allocate , dtype = torch . int8 , device = constants . device )
Allocates tensors for the node features, edge features, NLLs, and
termination status for all graphs to be generated.
Allocates tensors for the node features edge features NLLs and termination status for all graphs to be generated .
"""
        Allocates tensors for the node features, edge features, NLLs, and
        termination status for all graphs to be generated. These then get filled
        in during the graph generation process.
        """ # define tensor shapes # the 2 is arbitrary # allocate a buffer equal to the size of an extra batch # create the placeholder tensors: # placeholder for node features tensor for all graphs # placeholder for edge features tensor for all graphs # placeholder for number of nodes per graph in all graphs # placeholder for sampled NLL per action for all graphs # placeholder for sampled NLLs per action for all finished graphs # placeholder for graph termination status (1 == properly terminated, # 0 == improper)
self