Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion speechbrain/nnet/losses.py
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ def compute_length_mask(data, length=None, len_dim=1):
mask = torch.ones_like(data)
if length is not None:
length_mask = length_to_mask(
length * data.shape[len_dim],
(length * data.shape[len_dim] - 1e-6),
max_len=data.shape[len_dim],
)

Expand Down
4 changes: 2 additions & 2 deletions speechbrain/processing/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -1545,7 +1545,7 @@ def _load(self, path, end_of_epoch=False):
self._load_statistics_dict(stats)


def make_padding_mask(x, lengths=None, length_dim=1, eps=1e-8):
def make_padding_mask(x, lengths=None, length_dim=1, eps=1e-6):
"""Create a mask from relative lengths along a given dimension.

Arguments
Expand Down Expand Up @@ -1597,7 +1597,7 @@ def make_padding_mask(x, lengths=None, length_dim=1, eps=1e-8):

# Convert relative lengths to absolute lengths, then compute boolean mask
max_len = x.size(length_dim)
abs_lengths = (lengths * max_len + eps).unsqueeze(1)
abs_lengths = (lengths * max_len - eps).unsqueeze(1)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch here, I assume this is the cause of the failing tests?

mask = torch.arange(max_len, device=x.device).unsqueeze(0) < abs_lengths

# Add dimensions other than (batch, length) back into the mask
Expand Down
Loading