Skip to content

Commit 233f69f

Browse files
committed
fix use of max reduction in uncertainty estimator
1 parent c2b3a9e commit 233f69f

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

ncalab/uncertainty/uncertainty_estimator.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def estimate(
4646
if reduce == "mean":
4747
score = torch.mean(heatmap, dim=(2, 3))
4848
elif reduce == "max":
49-
score = torch.max(image, dim=(2, 3))
49+
score, _ = torch.max(torch.max(image, dim=2)[0], dim=2)
5050
else:
5151
score = torch.mean(heatmap, dim=(2, 3))
5252
return heatmap, predictions, score
@@ -122,14 +122,12 @@ def _estimate(self, image: torch.Tensor) -> Tuple[torch.Tensor, List[Prediction]
122122
"""
123123
self.nca.eval()
124124
heatmap = torch.zeros_like(image)
125-
sequence = self.nca.record(image)[-self.N_last:]
125+
sequence = self.nca.record(image)[-self.N_last :]
126126
output_images = torch.stack(
127127
[prediction.hidden_channels for prediction in sequence]
128128
)
129129

130-
heatmap = torch.std(
131-
output_images, dim=0
132-
)
130+
heatmap = torch.std(output_images, dim=0)
133131
if self.normalize:
134132
normalization = 10
135133
heatmap /= normalization

0 commit comments

Comments
 (0)