graphinvent/Workflow.py
def generate_graphs(self, n_samples : int, evaluation : bool=False) -> None:
        """
        Generates molecular graphs and evaluates them. Generates the graphs in
        batches of either the size of the mini-batches or `n_samples`, whichever
        is smaller.

        Args:
        ----
            n_samples (int)   : How many graphs to generate.
            evaluation (bool) : Indicates whether the model will be evaluated,
                                in which case we will also need the NLL per
                                action for the generated graphs.
        """
        print(f"* Generating {n_samples} molecules.", flush=True)
        generation_batch_size = min(self.constants.batch_size, n_samples)
        n_generation_batches  = int(n_samples/generation_batch_size)

        generator = GraphGenerator(model=self.model,
                                   batch_size=generation_batch_size)

        # generate graphs in batches
        for idx in range(0, n_generation_batches + 1):
            print("Batch", idx, "of", n_generation_batches)

            # generate one batch of graphs
            (graphs, action_likelihoods, final_loglikelihoods,
             termination) = generator.sample()

            # analyze properties of new graphs and save results
            self.analyzer.evaluate_generated_graphs(
                generated_graphs=graphs,
                termination=termination,
                loglikelihoods=final_loglikelihoods,
                ts_properties=self.ts_properties,
                generation_batch_idx=idx
            )

            # keep track of NLLs per action; note that only NLLs for the first
            # batch are kept, as only a few are needed to evaluate the model
            # (more efficient than saving all)
            if evaluation and idx == 0:
                self.likelihood_per_action = action_likelihoods

        Generates molecular graphs and evaluates them. Generates the graphs in
        batches of either the size of the mini-batches or `n_samples`, whichever
        is smaller.

        Args:
        ----
            n_samples (int)   : How many graphs to generate.
            evaluation (bool) : Indicates whether the model will be evaluated,
                                in which case we will also need the NLL per
                                action for the generated graphs.
        
Generates molecular graphs and evaluates them. Generates the graphs in
batches of either the size of the mini-batches or `n_samples`, whichever
is smaller.
Generates molecular graphs and evaluates them . Generates the graphs in batches of either the size of the mini - batches or ` n_samples ` whichever is smaller .
def generate_graphs(self, n_samples : int, evaluation : bool=False) -> None:
        print(f"* Generating {n_samples} molecules.", flush=True)
        generation_batch_size = min(self.constants.batch_size, n_samples)
        n_generation_batches  = int(n_samples/generation_batch_size)
        generator = GraphGenerator(model=self.model,
                                   batch_size=generation_batch_size)
        for idx in range(0, n_generation_batches + 1):
            print("Batch", idx, "of", n_generation_batches)
            (graphs, action_likelihoods, final_loglikelihoods,
             termination) = generator.sample()
            self.analyzer.evaluate_generated_graphs(
                generated_graphs=graphs,
                termination=termination,
                loglikelihoods=final_loglikelihoods,
                ts_properties=self.ts_properties,
                generation_batch_idx=idx
            )
            if evaluation and idx == 0:
                self.likelihood_per_action = action_likelihoods
def generate_graphs ( self , n_samples : int , evaluation : bool = False ) -> None : print ( f"* Generating {n_samples} molecules." , flush = True ) generation_batch_size = min ( self . constants . batch_size , n_samples ) n_generation_batches = int ( n_samples / generation_batch_size ) generator = GraphGenerator ( model = self . model , batch_size = generation_batch_size ) for idx in range ( 0 , n_generation_batches + 1 ) : print ( "Batch" , idx , "of" , n_generation_batches ) ( graphs , action_likelihoods , final_loglikelihoods , termination ) = generator . sample ( ) self . analyzer . evaluate_generated_graphs ( generated_graphs = graphs , termination = termination , loglikelihoods = final_loglikelihoods , ts_properties = self . ts_properties , generation_batch_idx = idx ) if evaluation and idx == 0 : self . likelihood_per_action = action_likelihoods
Generates molecular graphs and evaluates them.
Generates molecular graphs and evaluates them .
"""
        Generates molecular graphs and evaluates them. Generates the graphs in
        batches of either the size of the mini-batches or `n_samples`, whichever
        is smaller.

        Args:
        ----
            n_samples (int)   : How many graphs to generate.
            evaluation (bool) : Indicates whether the model will be evaluated,
                                in which case we will also need the NLL per
                                action for the generated graphs.
        """ # generate graphs in batches # generate one batch of graphs # analyze properties of new graphs and save results # keep track of NLLs per action; note that only NLLs for the first # batch are kept, as only a few are needed to evaluate the model # (more efficient than saving all)
self
n_samples
int
None
evaluation
bool
Indicates whether the model will be evaluated,
in which case we will also need the NLL per
action for the generated graphs.
Indicates whether the model will be evaluated in which case we will also need the NLL per action for the generated graphs .