graphinvent/Workflow.py
def loss(self, output : torch.Tensor, target_output : torch.Tensor) -> \
        torch.Tensor:
        """
        The graph generation loss is the KL divergence between the target and
        predicted actions.

        Args:
        ----
            output (torch.Tensor)        : Predicted APD tensor.
            target_output (torch.Tensor) : Target APD tensor.

        Returns:
        -------
            loss (torch.Tensor) : Average loss for this output.
        """
        # define activation function; note that one must use the softmax in the
        # KLDiv, never the sigmoid, as the distribution must sum to 1
        LogSoftmax = torch.nn.LogSoftmax(dim=1)
        output     = LogSoftmax(output)

        # normalize the target output (as can contain information on > 1 graph)
        target_output = target_output/torch.sum(target_output, dim=1, keepdim=True)

        # define loss function and calculate the los
        criterion = torch.nn.KLDivLoss(reduction="batchmean")
        loss      = criterion(target=target_output, input=output)

        return loss

        The graph generation loss is the KL divergence between the target and
        predicted actions.

        Args:
        ----
            output (torch.Tensor)        : Predicted APD tensor.
            target_output (torch.Tensor) : Target APD tensor.

        Returns:
        -------
            loss (torch.Tensor) : Average loss for this output.
        
The graph generation loss is the KL divergence between the target and
predicted actions.
The graph generation loss is the KL divergence between the target and predicted actions .
def loss(self, output : torch.Tensor, target_output : torch.Tensor) -> \
        torch.Tensor:
        LogSoftmax = torch.nn.LogSoftmax(dim=1)
        output     = LogSoftmax(output)
        target_output = target_output/torch.sum(target_output, dim=1, keepdim=True)
        criterion = torch.nn.KLDivLoss(reduction="batchmean")
        loss      = criterion(target=target_output, input=output)
        return loss
def loss ( self , output : torch . Tensor , target_output : torch . Tensor ) -> torch . Tensor : LogSoftmax = torch . nn . LogSoftmax ( dim = 1 ) output = LogSoftmax ( output ) target_output = target_output / torch . sum ( target_output , dim = 1 , keepdim = True ) criterion = torch . nn . KLDivLoss ( reduction = "batchmean" ) loss = criterion ( target = target_output , input = output ) return loss
The graph generation loss is the KL divergence between the target and
predicted actions.
The graph generation loss is the KL divergence between the target and predicted actions .
"""
        The graph generation loss is the KL divergence between the target and
        predicted actions.

        Args:
        ----
            output (torch.Tensor)        : Predicted APD tensor.
            target_output (torch.Tensor) : Target APD tensor.

        Returns:
        -------
            loss (torch.Tensor) : Average loss for this output.
        """ # define activation function; note that one must use the softmax in the # KLDiv, never the sigmoid, as the distribution must sum to 1 # normalize the target output (as can contain information on > 1 graph) # define loss function and calculate the los
loss (torch.Tensor) : Average loss for this output.
loss ( torch . Tensor ) : Average loss for this output .
self
output
torch.Tensor
Predicted APD tensor.
Predicted APD tensor .
target_output
torch.Tensor
Target APD tensor.
Target APD tensor .