MaskedBinaryCrossEntropy
Bases: tf.keras.losses.Loss
Compute Binary Cross-Entropy with masking.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mask_value |
int
|
value in y_true to be masked. |
None
|
name |
str
|
name of the loss function. |
'masked_binary_crossentropy'
|
reduction |
str
|
reduction method for the loss. |
'none'
|
call(y_true, y_pred)
Calculate masked binary cross-entropy.
Define as:
where is the target, and is the prediction is the mask, and is the number of unmasked units.
Warning
"" is element-wise multiplication.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
y_true |
tf.Tensor
|
target y with shape (batch_size, seq_len, feature) |
required |
y_pred |
tf.Tensor
|
predicted y with shape (batch_size, seq_len, feature) |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Loss |
tf.Tensor
|
Loss values with shape (batch_size) |