Skip to content

Commit ea4e066

Browse files
author
Rogier van Dalen
committed
Niceties
1 parent 77aa8b8 commit ea4e066

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

speechbrain/processing/features.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,11 +1072,12 @@ def normalise_dimensions(
10721072
masked_data = x if mask is None else mask * x
10731073

10741074
# First keep the dimensions so that broadcasting works.
1075-
sum_with_dims = torch.sum(masked_data, dim=reduce_dimensions, keepdim=True)
1076-
1077-
mean_with_dims = sum_with_dims / number
1078-
1075+
# If number == 0, the following will generate a warning, as it should.
1076+
mean_with_dims = (
1077+
torch.sum(masked_data, dim=reduce_dimensions, keepdim=True) / number
1078+
)
10791079
mean = torch.squeeze(mean_with_dims, dim=reduce_dimensions)
1080+
10801081
central_squared_data = torch.square(x - mean_with_dims)
10811082
masked_squared_data = (
10821083
central_squared_data if mask is None else mask * central_squared_data

0 commit comments

Comments
 (0)