From fe2f54aa5bc42fb23a96449cf90434ab9bb6a2cd Mon Sep 17 00:00:00 2001 From: Surya <116063290+SuryanarayanaY@users.noreply.github.com> Date: Thu, 21 Dec 2023 11:40:45 +0530 Subject: [PATCH] Correct the Error description in cropping layer APIs (#18974) * Correct the Error description in cropping APIs * Fix failing cropping test cases --- keras/layers/reshaping/cropping1d.py | 4 ++-- keras/layers/reshaping/cropping1d_test.py | 4 ++-- keras/layers/reshaping/cropping2d.py | 8 ++++---- keras/layers/reshaping/cropping2d_test.py | 2 +- keras/layers/reshaping/cropping3d.py | 4 ++-- keras/layers/reshaping/cropping3d_test.py | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/keras/layers/reshaping/cropping1d.py b/keras/layers/reshaping/cropping1d.py index 2b775e6fbd8..5788ce8f77a 100644 --- a/keras/layers/reshaping/cropping1d.py +++ b/keras/layers/reshaping/cropping1d.py @@ -54,7 +54,7 @@ def compute_output_shape(self, input_shape): if length <= 0: raise ValueError( "`cropping` parameter of `Cropping1D` layer must be " - "greater than the input length. Received: input_shape=" + "smaller than the input length. Received: input_shape=" f"{input_shape}, cropping={self.cropping}" ) else: @@ -68,7 +68,7 @@ def call(self, inputs): ): raise ValueError( "`cropping` parameter of `Cropping1D` layer must be " - "greater than the input length. Received: inputs.shape=" + "smaller than the input length. Received: inputs.shape=" f"{inputs.shape}, cropping={self.cropping}" ) if self.cropping[1] == 0: diff --git a/keras/layers/reshaping/cropping1d_test.py b/keras/layers/reshaping/cropping1d_test.py index 80d348ab98e..085466b0412 100644 --- a/keras/layers/reshaping/cropping1d_test.py +++ b/keras/layers/reshaping/cropping1d_test.py @@ -64,7 +64,7 @@ def test_cropping_1d_errors_if_cropping_argument_invalid(self): def test_cropping_1d_errors_if_cropping_more_than_available(self): with self.assertRaisesRegex( ValueError, - "`cropping` parameter of `Cropping1D` layer must be greater than", + "`cropping` parameter of `Cropping1D` layer must be smaller than", ): input_layer = layers.Input(batch_shape=(3, 5, 7)) layers.Cropping1D(cropping=(2, 3))(input_layer) @@ -74,7 +74,7 @@ def test_cropping_1d_error_on_excessive_cropping(self): with self.assertRaisesRegex( ValueError, - "`cropping` parameter of `Cropping1D` layer must be greater than", + "`cropping` parameter of `Cropping1D` layer must be smaller than", ): layer = layers.Cropping1D(cropping=(3, 3)) _ = layer(inputs) diff --git a/keras/layers/reshaping/cropping2d.py b/keras/layers/reshaping/cropping2d.py index 867ea0512bf..ff9f3e70437 100644 --- a/keras/layers/reshaping/cropping2d.py +++ b/keras/layers/reshaping/cropping2d.py @@ -96,7 +96,7 @@ def compute_output_shape(self, input_shape): and sum(self.cropping[1]) >= input_shape[3] ): raise ValueError( - "Values in `cropping` argument should be greater than the " + "Values in `cropping` argument should be smaller than the " "corresponding spatial dimension of the input. Received: " f"input_shape={input_shape}, cropping={self.cropping}" ) @@ -119,7 +119,7 @@ def compute_output_shape(self, input_shape): and sum(self.cropping[1]) >= input_shape[2] ): raise ValueError( - "Values in `cropping` argument should be greater than the " + "Values in `cropping` argument should be smaller than the " "corresponding spatial dimension of the input. Received: " f"input_shape={input_shape}, cropping={self.cropping}" ) @@ -144,7 +144,7 @@ def call(self, inputs): and sum(self.cropping[1]) >= inputs.shape[3] ): raise ValueError( - "Values in `cropping` argument should be greater than the " + "Values in `cropping` argument should be smaller than the " "corresponding spatial dimension of the input. Received: " f"inputs.shape={inputs.shape}, cropping={self.cropping}" ) @@ -181,7 +181,7 @@ def call(self, inputs): and sum(self.cropping[1]) >= inputs.shape[2] ): raise ValueError( - "Values in `cropping` argument should be greater than the " + "Values in `cropping` argument should be smaller than the " "corresponding spatial dimension of the input. Received: " f"inputs.shape={inputs.shape}, cropping={self.cropping}" ) diff --git a/keras/layers/reshaping/cropping2d_test.py b/keras/layers/reshaping/cropping2d_test.py index b6a0d5322c3..fbf88695fd8 100644 --- a/keras/layers/reshaping/cropping2d_test.py +++ b/keras/layers/reshaping/cropping2d_test.py @@ -126,7 +126,7 @@ def test_cropping_2d_error_on_excessive_cropping( with self.assertRaisesRegex( ValueError, - "Values in `cropping` argument should be greater than the " + "Values in `cropping` argument should be smaller than the " "corresponding spatial dimension of the input.", ): layer = layers.Cropping2D( diff --git a/keras/layers/reshaping/cropping3d.py b/keras/layers/reshaping/cropping3d.py index 7c415595ca9..ca03296e0d3 100644 --- a/keras/layers/reshaping/cropping3d.py +++ b/keras/layers/reshaping/cropping3d.py @@ -112,7 +112,7 @@ def compute_output_shape(self, input_shape): spatial_dims[index] -= sum(self.cropping[index]) if spatial_dims[index] <= 0: raise ValueError( - "Values in `cropping` argument should be greater than the " + "Values in `cropping` argument should be smaller than the " "corresponding spatial dimension of the input. Received: " f"input_shape={input_shape}, cropping={self.cropping}" ) @@ -134,7 +134,7 @@ def call(self, inputs): spatial_dims[index] -= sum(self.cropping[index]) if spatial_dims[index] <= 0: raise ValueError( - "Values in `cropping` argument should be greater than the " + "Values in `cropping` argument should be smaller than the " "corresponding spatial dimension of the input. Received: " f"inputs.shape={inputs.shape}, cropping={self.cropping}" ) diff --git a/keras/layers/reshaping/cropping3d_test.py b/keras/layers/reshaping/cropping3d_test.py index 242edb1f0dd..93aeaabe844 100644 --- a/keras/layers/reshaping/cropping3d_test.py +++ b/keras/layers/reshaping/cropping3d_test.py @@ -190,7 +190,7 @@ def test_cropping_3d_with_excessive_cropping(self, cropping, data_format): input_layer = layers.Input(batch_shape=shape) expected_error_msg = ( - "Values in `cropping` argument should be greater than the" + "Values in `cropping` argument should be smaller than the" ) with self.assertRaisesRegex(ValueError, expected_error_msg):