Skip to content

Commit f1cc2e6

Browse files
authored
fix: bug in variables ordering in NormalizedReluBounding (#98)
This bug is fixed by making sure that self.norm_min_val follows the same order as self.data_index. --------- Reviewed-by: @sahahner
1 parent abbef4b commit f1cc2e6

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

models/src/anemoi/models/layers/bounding.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ def __init__(
135135
"The length of the min_val list must match the number of variables in NormalizedReluBounding."
136136
)
137137

138+
# Compute normalized min values
139+
self.data_index = [name_to_index[var] for var in variables]
138140
self.norm_min_val = torch.zeros(len(variables))
139141
for ii, variable in enumerate(variables):
140142
stat_index = self.name_to_index_stats[variable]

models/tests/layers/test_bounding.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ def test_normalized_relu_bounding(config, name_to_index, name_to_index_stats, in
6767
name_to_index_stats=name_to_index_stats,
6868
)
6969
output = bounding(input_tensor.clone())
70-
# breakpoint()
7170
expected_output = torch.tensor([[2.0, 2.0, 3.0], [4.0, 0.1111, 6.0], [2.0, 0.5, 0.5]])
7271
assert torch.allclose(output, expected_output, atol=1e-4)
7372

0 commit comments

Comments
 (0)