Skip to content

Instantly share code, notes, and snippets.

@MathiasGruber
Last active July 2, 2021 04:56
Show Gist options
  • Save MathiasGruber/7efd1f8e39cc0750b22de1435967f335 to your computer and use it in GitHub Desktop.
Save MathiasGruber/7efd1f8e39cc0750b22de1435967f335 to your computer and use it in GitHub Desktop.
Small wrapper function for the torch cross-entropy loss
def cross_entropy(predictions: List[List[float]], targets: List[float]):
return nn.CrossEntropyLoss(reduction='none')(predictions, target)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment