graphinvent/GraphGenerator.py
def _reshape_apd(apds : torch.Tensor, batch_size : int) -> \
            Tuple[torch.Tensor, ...]:
            """
            Reshapes the input batch of APDs (inverse to flattening).

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

            Returns:
            -------
                f_add (torch.Tensor)  : Reshaped APD segment for "add" action.
                f_conn (torch.Tensor) : Reshaped APD segment for "connect"
                                        action.
                f_term (torch.Tensor) : Reshaped APD segment for "terminate"
                                        action.
            """
            # get shapes of "add" and "connect" actions
            f_add_shape = (batch_size, *constants.dim_f_add)
            f_conn_shape = (batch_size, *constants.dim_f_conn)

            # get len of flattened segment of APD corresponding to "add" action
            f_add_size = np.prod(constants.dim_f_add)

            # reshape the various APD components
            f_add = torch.reshape(apds[:, :f_add_size], f_add_shape)
            f_conn = torch.reshape(apds[:, f_add_size:-1], f_conn_shape)
            f_term = apds[:, -1]

            return f_add, f_conn, f_term

            Reshapes the input batch of APDs (inverse to flattening).

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

            Returns:
            -------
                f_add (torch.Tensor)  : Reshaped APD segment for "add" action.
                f_conn (torch.Tensor) : Reshaped APD segment for "connect"
                                        action.
                f_term (torch.Tensor) : Reshaped APD segment for "terminate"
                                        action.
            
Reshapes the input batch of APDs (inverse to flattening).
Reshapes the input batch of APDs ( inverse to flattening ) .
def _reshape_apd(apds : torch.Tensor, batch_size : int) -> \
            Tuple[torch.Tensor, ...]:
            f_add_shape = (batch_size, *constants.dim_f_add)
            f_conn_shape = (batch_size, *constants.dim_f_conn)
            f_add_size = np.prod(constants.dim_f_add)
            f_add = torch.reshape(apds[:, :f_add_size], f_add_shape)
            f_conn = torch.reshape(apds[:, f_add_size:-1], f_conn_shape)
            f_term = apds[:, -1]
            return f_add, f_conn, f_term
def _reshape_apd ( apds : torch . Tensor , batch_size : int ) -> Tuple [ torch . Tensor , ... ] : f_add_shape = ( batch_size , * constants . dim_f_add ) f_conn_shape = ( batch_size , * constants . dim_f_conn ) f_add_size = np . prod ( constants . dim_f_add ) f_add = torch . reshape ( apds [ : , : f_add_size ] , f_add_shape ) f_conn = torch . reshape ( apds [ : , f_add_size : - 1 ] , f_conn_shape ) f_term = apds [ : , - 1 ] return f_add , f_conn , f_term
Reshapes the input batch of APDs (inverse to flattening).
Reshapes the input batch of APDs ( inverse to flattening ) .
"""
            Reshapes the input batch of APDs (inverse to flattening).

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

            Returns:
            -------
                f_add (torch.Tensor)  : Reshaped APD segment for "add" action.
                f_conn (torch.Tensor) : Reshaped APD segment for "connect"
                                        action.
                f_term (torch.Tensor) : Reshaped APD segment for "terminate"
                                        action.
            """ # get shapes of "add" and "connect" actions # get len of flattened segment of APD corresponding to "add" action # reshape the various APD components
f_add (torch.Tensor)  : Reshaped APD segment for "add" action.
f_conn (torch.Tensor) : Reshaped APD segment for "connect"
action.
f_term (torch.Tensor) : Reshaped APD segment for "terminate"
action.
f_add ( torch . Tensor ) : Reshaped APD segment for " add " action . f_conn ( torch . Tensor ) : Reshaped APD segment for " connect " action . f_term ( torch . Tensor ) : Reshaped APD segment for " terminate " action .
apds
torch.Tensor
APDs for a batch of graphs.
APDs for a batch of graphs .
batch_size
int
None