graphinvent/GraphGenerator.py
def copy_terminated_graphs(self, terminate_idc : torch.Tensor,
                               n_graphs_generated : int, generation_round : int,
                               likelihoods_sampled : torch.Tensor) -> int:
        """
        Copies terminated graphs (either because "terminate" action sampled, or
        invalid action sampled) to `generated_nodes` and `generated_edges`
        before they are removed from the running batch of graphs being generated.

        Args:
        ----
            terminate_idc (torch.Tensor) : Indices for graphs that will terminate
                                           this round.
            n_graphs_generated (int)     : Number of graphs generated thus far (not
                                           including those about to be copied).
            generation_round (int)       : Indicates the current generation round
                                           (running count).
            likelihoods_sampled (torch.Tensor) : NLLs for the newest sampled action
                                                 for each graph in a batch of graphs
                                                 (not yet included in `likelihoods`).

        Returns:
        -------
            n_graphs_generated (int) : Number of graphs generated thus far.
        """
        # number of graphs to be terminated
        self.likelihoods[terminate_idc, generation_round] = likelihoods_sampled[terminate_idc]

        # number of graphs to be terminated
        n_done_graphs = len(terminate_idc)

        # copy the new graphs to the finished tensors
        nodes_local = self.nodes[terminate_idc]
        edges_local = self.edges[terminate_idc]
        n_nodes_local = self.n_nodes[terminate_idc]
        likelihoods_local = self.likelihoods[terminate_idc]

        begin_idx = n_graphs_generated
        end_idx = n_graphs_generated + n_done_graphs
        self.generated_nodes[begin_idx : end_idx] = nodes_local
        self.generated_edges[begin_idx : end_idx] = edges_local
        self.generated_n_nodes[begin_idx : end_idx] = n_nodes_local
        self.generated_likelihoods[begin_idx : end_idx] = likelihoods_local

        n_graphs_generated += n_done_graphs

        return n_graphs_generated

        Copies terminated graphs (either because "terminate" action sampled, or
        invalid action sampled) to `generated_nodes` and `generated_edges`
        before they are removed from the running batch of graphs being generated.

        Args:
        ----
            terminate_idc (torch.Tensor) : Indices for graphs that will terminate
                                           this round.
            n_graphs_generated (int)     : Number of graphs generated thus far (not
                                           including those about to be copied).
            generation_round (int)       : Indicates the current generation round
                                           (running count).
            likelihoods_sampled (torch.Tensor) : NLLs for the newest sampled action
                                                 for each graph in a batch of graphs
                                                 (not yet included in `likelihoods`).

        Returns:
        -------
            n_graphs_generated (int) : Number of graphs generated thus far.
        
Copies terminated graphs (either because "terminate" action sampled, or
invalid action sampled) to `generated_nodes` and `generated_edges`
before they are removed from the running batch of graphs being generated.
Copies terminated graphs ( either because " terminate " action sampled or invalid action sampled ) to ` generated_nodes ` and ` generated_edges ` before they are removed from the running batch of graphs being generated .
def copy_terminated_graphs(self, terminate_idc : torch.Tensor,
                               n_graphs_generated : int, generation_round : int,
                               likelihoods_sampled : torch.Tensor) -> int:
        self.likelihoods[terminate_idc, generation_round] = likelihoods_sampled[terminate_idc]
        n_done_graphs = len(terminate_idc)
        nodes_local = self.nodes[terminate_idc]
        edges_local = self.edges[terminate_idc]
        n_nodes_local = self.n_nodes[terminate_idc]
        likelihoods_local = self.likelihoods[terminate_idc]
        begin_idx = n_graphs_generated
        end_idx = n_graphs_generated + n_done_graphs
        self.generated_nodes[begin_idx : end_idx] = nodes_local
        self.generated_edges[begin_idx : end_idx] = edges_local
        self.generated_n_nodes[begin_idx : end_idx] = n_nodes_local
        self.generated_likelihoods[begin_idx : end_idx] = likelihoods_local
        n_graphs_generated += n_done_graphs
        return n_graphs_generated
def copy_terminated_graphs ( self , terminate_idc : torch . Tensor , n_graphs_generated : int , generation_round : int , likelihoods_sampled : torch . Tensor ) -> int : self . likelihoods [ terminate_idc , generation_round ] = likelihoods_sampled [ terminate_idc ] n_done_graphs = len ( terminate_idc ) nodes_local = self . nodes [ terminate_idc ] edges_local = self . edges [ terminate_idc ] n_nodes_local = self . n_nodes [ terminate_idc ] likelihoods_local = self . likelihoods [ terminate_idc ] begin_idx = n_graphs_generated end_idx = n_graphs_generated + n_done_graphs self . generated_nodes [ begin_idx : end_idx ] = nodes_local self . generated_edges [ begin_idx : end_idx ] = edges_local self . generated_n_nodes [ begin_idx : end_idx ] = n_nodes_local self . generated_likelihoods [ begin_idx : end_idx ] = likelihoods_local n_graphs_generated += n_done_graphs return n_graphs_generated
Copies terminated graphs (either because "terminate" action sampled, or
invalid action sampled) to `generated_nodes` and `generated_edges`
before they are removed from the running batch of graphs being generated.
Copies terminated graphs ( either because " terminate " action sampled or invalid action sampled ) to ` generated_nodes ` and ` generated_edges ` before they are removed from the running batch of graphs being generated .
"""
        Copies terminated graphs (either because "terminate" action sampled, or
        invalid action sampled) to `generated_nodes` and `generated_edges`
        before they are removed from the running batch of graphs being generated.

        Args:
        ----
            terminate_idc (torch.Tensor) : Indices for graphs that will terminate
                                           this round.
            n_graphs_generated (int)     : Number of graphs generated thus far (not
                                           including those about to be copied).
            generation_round (int)       : Indicates the current generation round
                                           (running count).
            likelihoods_sampled (torch.Tensor) : NLLs for the newest sampled action
                                                 for each graph in a batch of graphs
                                                 (not yet included in `likelihoods`).

        Returns:
        -------
            n_graphs_generated (int) : Number of graphs generated thus far.
        """ # number of graphs to be terminated # number of graphs to be terminated # copy the new graphs to the finished tensors
n_graphs_generated (int) : Number of graphs generated thus far.
n_graphs_generated ( int ) : Number of graphs generated thus far .
self
terminate_idc
torch.Tensor
Indices for graphs that will terminate
this round.
Indices for graphs that will terminate this round .
n_graphs_generated
int
Number of graphs generated thus far (not
including those about to be copied).
Number of graphs generated thus far ( not including those about to be copied ) .
generation_round
int
Indicates the current generation round
(running count).
Indicates the current generation round ( running count ) .
likelihoods_sampled
torch.Tensor
NLLs for the newest sampled action
for each graph in a batch of graphs
(not yet included in `likelihoods`).
NLLs for the newest sampled action for each graph in a batch of graphs ( not yet included in ` likelihoods ` ) .