Losses

BinaryClassificationLoss

class relational_transformers.BinaryClassificationLoss(*args, **kwargs)

Binary cross entropy over one logit per relational context.

forward(logits, labels)

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Parameters:
  • logits (Tensor)

  • labels (Tensor)

Return type:

Tensor

MulticlassClassificationLoss

class relational_transformers.MulticlassClassificationLoss(*args, **kwargs)

Cross entropy over mutually exclusive class logits.

forward(logits, labels)

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Parameters:
  • logits (Tensor)

  • labels (Tensor)

Return type:

Tensor

MultilabelClassificationLoss

class relational_transformers.MultilabelClassificationLoss(*args, **kwargs)

Binary cross entropy over independent label logits.

forward(logits, labels)

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Parameters:
  • logits (Tensor)

  • labels (Tensor)

Return type:

Tensor

RegressionLoss

class relational_transformers.RegressionLoss(delta=1.0)

Huber loss for regression and forecasting targets.

Parameters:

delta (float)

forward(predictions, labels)

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Parameters:
  • predictions (Tensor)

  • labels (Tensor)

Return type:

Tensor