graphinvent/GraphGenerator.py
def _sample_apd(apds : torch.Tensor, batch_size : int) -> \
            Tuple[torch.Tensor, ...]:
            """
            Samples the input APDs for all graphs in the batch.

            Args:
            ----
                apds (torch.Tensor) : APDs for a batch of graphs.
                batch_size (int)    : Batch size.

            Returns:
            -------
                add_idc (torch.Tensor)     : Nonzero elements in `f_add`.
                conn_idc (torch.Tensor)    : Nonzero elements in `f_conn`.
                term_idc (torch.Tensor)    : Nonzero elements in `f_term`.
                likelihoods (torch.Tensor) : Contains NLLs for samples actions.
            """
            action_probability_distribution = torch.distributions.Multinomial(
                1,
                probs=apds
            )
            apd_one_hot = action_probability_distribution.sample()
            f_add, f_conn, f_term = _reshape_apd(apd_one_hot, batch_size)

            likelihoods = apds[apd_one_hot == 1]

            add_idc = torch.nonzero(f_add, as_tuple=True)
            conn_idc = torch.nonzero(f_conn, as_tuple=True)
            term_idc = torch.nonzero(f_term).view(-1)

            return add_idc, conn_idc, term_idc, likelihoods

            Samples the input APDs for all graphs in the batch.

            Args:
            ----
                apds (torch.Tensor) : APDs for a batch of graphs.
                batch_size (int)    : Batch size.

            Returns:
            -------
                add_idc (torch.Tensor)     : Nonzero elements in `f_add`.
                conn_idc (torch.Tensor)    : Nonzero elements in `f_conn`.
                term_idc (torch.Tensor)    : Nonzero elements in `f_term`.
                likelihoods (torch.Tensor) : Contains NLLs for samples actions.
            
Samples the input APDs for all graphs in the batch.
Samples the input APDs for all graphs in the batch .
def _sample_apd(apds : torch.Tensor, batch_size : int) -> \
            Tuple[torch.Tensor, ...]:
            action_probability_distribution = torch.distributions.Multinomial(
                1,
                probs=apds
            )
            apd_one_hot = action_probability_distribution.sample()
            f_add, f_conn, f_term = _reshape_apd(apd_one_hot, batch_size)
            likelihoods = apds[apd_one_hot == 1]
            add_idc = torch.nonzero(f_add, as_tuple=True)
            conn_idc = torch.nonzero(f_conn, as_tuple=True)
            term_idc = torch.nonzero(f_term).view(-1)
            return add_idc, conn_idc, term_idc, likelihoods
def _sample_apd ( apds : torch . Tensor , batch_size : int ) -> Tuple [ torch . Tensor , ... ] : action_probability_distribution = torch . distributions . Multinomial ( 1 , probs = apds ) apd_one_hot = action_probability_distribution . sample ( ) f_add , f_conn , f_term = _reshape_apd ( apd_one_hot , batch_size ) likelihoods = apds [ apd_one_hot == 1 ] add_idc = torch . nonzero ( f_add , as_tuple = True ) conn_idc = torch . nonzero ( f_conn , as_tuple = True ) term_idc = torch . nonzero ( f_term ) . view ( - 1 ) return add_idc , conn_idc , term_idc , likelihoods
Samples the input APDs for all graphs in the batch.
Samples the input APDs for all graphs in the batch .
"""
            Samples the input APDs for all graphs in the batch.

            Args:
            ----
                apds (torch.Tensor) : APDs for a batch of graphs.
                batch_size (int)    : Batch size.

            Returns:
            -------
                add_idc (torch.Tensor)     : Nonzero elements in `f_add`.
                conn_idc (torch.Tensor)    : Nonzero elements in `f_conn`.
                term_idc (torch.Tensor)    : Nonzero elements in `f_term`.
                likelihoods (torch.Tensor) : Contains NLLs for samples actions.
            """
add_idc (torch.Tensor)     : Nonzero elements in `f_add`.
conn_idc (torch.Tensor)    : Nonzero elements in `f_conn`.
term_idc (torch.Tensor)    : Nonzero elements in `f_term`.
likelihoods (torch.Tensor) : Contains NLLs for samples actions.
add_idc ( torch . Tensor ) : Nonzero elements in ` f_add ` . conn_idc ( torch . Tensor ) : Nonzero elements in ` f_conn ` . term_idc ( torch . Tensor ) : Nonzero elements in ` f_term ` . likelihoods ( torch . Tensor ) : Contains NLLs for samples actions .
apds
torch.Tensor
APDs for a batch of graphs.
APDs for a batch of graphs .
batch_size
int
None