Binary Cross Entropy Loss
BinLoss
Bases: Module
Binary cross-entropy loss for hard and soft attention.
Attributes None
Methods forward: Computes the binary cross-entropy loss for hard and soft attention.
Source code in training/loss/bin_loss.py
forward(hard_attention, soft_attention)
Computes the binary cross-entropy loss for hard and soft attention.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hard_attention |
Tensor
|
A binary tensor indicating the hard attention. |
required |
soft_attention |
Tensor
|
A tensor containing the soft attention probabilities. |
required |
Returns:
Type | Description |
---|---|
Tensor
|
torch.Tensor: The binary cross-entropy loss. |