We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 77aa8b8 commit ea4e066Copy full SHA for ea4e066
1 file changed
speechbrain/processing/features.py
@@ -1072,11 +1072,12 @@ def normalise_dimensions(
1072
masked_data = x if mask is None else mask * x
1073
1074
# 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
+ # If number == 0, the following will generate a warning, as it should.
+ mean_with_dims = (
+ torch.sum(masked_data, dim=reduce_dimensions, keepdim=True) / number
+ )
1079
mean = torch.squeeze(mean_with_dims, dim=reduce_dimensions)
1080
+
1081
central_squared_data = torch.square(x - mean_with_dims)
1082
masked_squared_data = (
1083
central_squared_data if mask is None else mask * central_squared_data
0 commit comments