Skip to content

Commit fe2f54a

Browse files
Correct the Error description in cropping layer APIs (#18974)
* Correct the Error description in cropping APIs * Fix failing cropping test cases
1 parent e51ecdd commit fe2f54a

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

keras/layers/reshaping/cropping1d.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def compute_output_shape(self, input_shape):
5454
if length <= 0:
5555
raise ValueError(
5656
"`cropping` parameter of `Cropping1D` layer must be "
57-
"greater than the input length. Received: input_shape="
57+
"smaller than the input length. Received: input_shape="
5858
f"{input_shape}, cropping={self.cropping}"
5959
)
6060
else:
@@ -68,7 +68,7 @@ def call(self, inputs):
6868
):
6969
raise ValueError(
7070
"`cropping` parameter of `Cropping1D` layer must be "
71-
"greater than the input length. Received: inputs.shape="
71+
"smaller than the input length. Received: inputs.shape="
7272
f"{inputs.shape}, cropping={self.cropping}"
7373
)
7474
if self.cropping[1] == 0:

keras/layers/reshaping/cropping1d_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def test_cropping_1d_errors_if_cropping_argument_invalid(self):
6464
def test_cropping_1d_errors_if_cropping_more_than_available(self):
6565
with self.assertRaisesRegex(
6666
ValueError,
67-
"`cropping` parameter of `Cropping1D` layer must be greater than",
67+
"`cropping` parameter of `Cropping1D` layer must be smaller than",
6868
):
6969
input_layer = layers.Input(batch_shape=(3, 5, 7))
7070
layers.Cropping1D(cropping=(2, 3))(input_layer)
@@ -74,7 +74,7 @@ def test_cropping_1d_error_on_excessive_cropping(self):
7474

7575
with self.assertRaisesRegex(
7676
ValueError,
77-
"`cropping` parameter of `Cropping1D` layer must be greater than",
77+
"`cropping` parameter of `Cropping1D` layer must be smaller than",
7878
):
7979
layer = layers.Cropping1D(cropping=(3, 3))
8080
_ = layer(inputs)

keras/layers/reshaping/cropping2d.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def compute_output_shape(self, input_shape):
9696
and sum(self.cropping[1]) >= input_shape[3]
9797
):
9898
raise ValueError(
99-
"Values in `cropping` argument should be greater than the "
99+
"Values in `cropping` argument should be smaller than the "
100100
"corresponding spatial dimension of the input. Received: "
101101
f"input_shape={input_shape}, cropping={self.cropping}"
102102
)
@@ -119,7 +119,7 @@ def compute_output_shape(self, input_shape):
119119
and sum(self.cropping[1]) >= input_shape[2]
120120
):
121121
raise ValueError(
122-
"Values in `cropping` argument should be greater than the "
122+
"Values in `cropping` argument should be smaller than the "
123123
"corresponding spatial dimension of the input. Received: "
124124
f"input_shape={input_shape}, cropping={self.cropping}"
125125
)
@@ -144,7 +144,7 @@ def call(self, inputs):
144144
and sum(self.cropping[1]) >= inputs.shape[3]
145145
):
146146
raise ValueError(
147-
"Values in `cropping` argument should be greater than the "
147+
"Values in `cropping` argument should be smaller than the "
148148
"corresponding spatial dimension of the input. Received: "
149149
f"inputs.shape={inputs.shape}, cropping={self.cropping}"
150150
)
@@ -181,7 +181,7 @@ def call(self, inputs):
181181
and sum(self.cropping[1]) >= inputs.shape[2]
182182
):
183183
raise ValueError(
184-
"Values in `cropping` argument should be greater than the "
184+
"Values in `cropping` argument should be smaller than the "
185185
"corresponding spatial dimension of the input. Received: "
186186
f"inputs.shape={inputs.shape}, cropping={self.cropping}"
187187
)

keras/layers/reshaping/cropping2d_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def test_cropping_2d_error_on_excessive_cropping(
126126

127127
with self.assertRaisesRegex(
128128
ValueError,
129-
"Values in `cropping` argument should be greater than the "
129+
"Values in `cropping` argument should be smaller than the "
130130
"corresponding spatial dimension of the input.",
131131
):
132132
layer = layers.Cropping2D(

keras/layers/reshaping/cropping3d.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def compute_output_shape(self, input_shape):
112112
spatial_dims[index] -= sum(self.cropping[index])
113113
if spatial_dims[index] <= 0:
114114
raise ValueError(
115-
"Values in `cropping` argument should be greater than the "
115+
"Values in `cropping` argument should be smaller than the "
116116
"corresponding spatial dimension of the input. Received: "
117117
f"input_shape={input_shape}, cropping={self.cropping}"
118118
)
@@ -134,7 +134,7 @@ def call(self, inputs):
134134
spatial_dims[index] -= sum(self.cropping[index])
135135
if spatial_dims[index] <= 0:
136136
raise ValueError(
137-
"Values in `cropping` argument should be greater than the "
137+
"Values in `cropping` argument should be smaller than the "
138138
"corresponding spatial dimension of the input. Received: "
139139
f"inputs.shape={inputs.shape}, cropping={self.cropping}"
140140
)

keras/layers/reshaping/cropping3d_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def test_cropping_3d_with_excessive_cropping(self, cropping, data_format):
190190
input_layer = layers.Input(batch_shape=shape)
191191

192192
expected_error_msg = (
193-
"Values in `cropping` argument should be greater than the"
193+
"Values in `cropping` argument should be smaller than the"
194194
)
195195

196196
with self.assertRaisesRegex(ValueError, expected_error_msg):

0 commit comments

Comments
 (0)