Skip to content

Commit

Permalink
Raise error when inputs and mask don't have same shape in Softmax
Browse files Browse the repository at this point in the history
  • Loading branch information
SuryanarayanaY committed May 20, 2024
1 parent a05ac12 commit 55d34df
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions keras/src/layers/activations/softmax.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ def __init__(self, axis=-1, **kwargs):

def call(self, inputs, mask=None):
if mask is not None:
if mask.shape != inputs.shape:
raise ValueError(
"`mask` and `inputs` must have same shape. "
f"Got inputs shape: {inputs.shape} and "
f"mask shape: {mask.shape}"
)
adder = (
1.0 - backend.cast(mask, inputs.dtype)
) * _large_negative_number(inputs.dtype)
Expand Down

0 comments on commit 55d34df

Please sign in to comment.