From 4f318f90761fde18e7d286f5d6bddbc5bc844382 Mon Sep 17 00:00:00 2001 From: Eric Brune Date: Mon, 28 Oct 2024 09:47:43 +0100 Subject: [PATCH 1/3] Fixed MinMax normalization --- pangaea/engine/data_preprocessor.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pangaea/engine/data_preprocessor.py b/pangaea/engine/data_preprocessor.py index 0e9bcb7..f82496f 100644 --- a/pangaea/engine/data_preprocessor.py +++ b/pangaea/engine/data_preprocessor.py @@ -381,9 +381,8 @@ def __call__( """ for k in self.data_min.keys(): - size = (-1,) + data["image"][k].shape[1:] - data["image"][k].sub_(self.data_min[k].view(size)).div_( - (self.data_max[k] - self.data_min[k]).view(size) + data["image"][k].sub_(self.data_min[k].view(-1, 1, 1, 1)).div_( + (self.data_max[k] - self.data_min[k]).view(-1, 1, 1, 1) ) return data From 2787927b0007d9800ca34b5766654fc65a19e160 Mon Sep 17 00:00:00 2001 From: Yuru Jia <91590963+yurujaja@users.noreply.github.com> Date: Mon, 28 Oct 2024 10:26:43 +0100 Subject: [PATCH 2/3] Update the docstring --- pangaea/engine/data_preprocessor.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pangaea/engine/data_preprocessor.py b/pangaea/engine/data_preprocessor.py index f82496f..2784431 100644 --- a/pangaea/engine/data_preprocessor.py +++ b/pangaea/engine/data_preprocessor.py @@ -351,11 +351,11 @@ def __init__( self, **meta, ) -> None: - """Initialize the NormalizeMeanStd. + """Initialize the NormalizeMinMax. Args: meta: statistics/info of the input data and target encoder - data_min: global maximum value of incoming data - data_sax: global minimum value of incoming data + data_min: global minimum value of incoming data + data_max: global maximum value of incoming data """ super().__init__() @@ -365,7 +365,7 @@ def __init__( def __call__( self, data: dict[str, torch.Tensor | dict[str, torch.Tensor]] ) -> dict[str, torch.Tensor | dict[str, torch.Tensor]]: - """Apply Mean/Std Normalization to the data. + """Apply Min/Max Normalization to the data. Args: data (dict): input data. Returns: From dff4d3801f434403684a1bd59ea9dc5adff71e64 Mon Sep 17 00:00:00 2001 From: Eric Brune Date: Mon, 28 Oct 2024 10:33:51 +0100 Subject: [PATCH 3/3] Fix reg_default.yaml --- configs/preprocessing/reg_default.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configs/preprocessing/reg_default.yaml b/configs/preprocessing/reg_default.yaml index 1d468b8..8b2e3fd 100644 --- a/configs/preprocessing/reg_default.yaml +++ b/configs/preprocessing/reg_default.yaml @@ -3,19 +3,19 @@ train: preprocessor_cfg: - _target_: pangaea.engine.data_preprocessor.RandomCropToEncoder - _target_: pangaea.engine.data_preprocessor.BandFilter - - _target_: pangaea.engine.data_preprocessor.NormalizeMeanStd + - _target_: pangaea.engine.data_preprocessor.NormalizeMinMax - _target_: pangaea.engine.data_preprocessor.BandPadding val: _target_: pangaea.engine.data_preprocessor.Preprocessor preprocessor_cfg: - _target_: pangaea.engine.data_preprocessor.BandFilter - - _target_: pangaea.engine.data_preprocessor.NormalizeMeanStd + - _target_: pangaea.engine.data_preprocessor.NormalizeMinMax - _target_: pangaea.engine.data_preprocessor.BandPadding test: _target_: pangaea.engine.data_preprocessor.Preprocessor preprocessor_cfg: - _target_: pangaea.engine.data_preprocessor.BandFilter - - _target_: pangaea.engine.data_preprocessor.NormalizeMeanStd + - _target_: pangaea.engine.data_preprocessor.NormalizeMinMax - _target_: pangaea.engine.data_preprocessor.BandPadding \ No newline at end of file