Skip to content

Commit 9e38e04

Browse files
Updated random_grayscale.py compute_output_spec (#21326)
* Update nn.py * Update nn.py * Update nn.py * Update nn.py * Update nn.py Corrected indentation in doc string * Update nn.py * Update random_grayscale.py Fixed issue with passing a single image without batch dimension. * Update keras/src/layers/preprocessing/image_preprocessing/random_grayscale.py Co-authored-by: Jyotinder Singh <[email protected]> * Update random_grayscale_test.py Test case for unbatched inputs * code reformat * Update random_grayscale_test.py Testcase for checking both unbatched and batched single image inputs. * changed compute_output_spec There was a bug, and it was causing cycle in graph. * Update random_grayscale.py removed the use of tree.map_structure --------- Co-authored-by: Jyotinder Singh <[email protected]>
1 parent 6b74cb0 commit 9e38e04

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

keras/src/layers/preprocessing/image_preprocessing/random_grayscale.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from keras.src import backend
2-
from keras.src import tree
32
from keras.src.api_export import keras_export
43
from keras.src.layers.preprocessing.image_preprocessing.base_image_preprocessing_layer import ( # noqa: E501
54
BaseImagePreprocessingLayer,
@@ -97,11 +96,8 @@ def compute_output_shape(self, input_shape):
9796
return input_shape
9897

9998
def compute_output_spec(self, inputs, **kwargs):
100-
return tree.map_structure(
101-
lambda x: backend.KerasTensor(
102-
x.shape, dtype=x.dtype, sparse=x.sparse
103-
),
104-
inputs,
99+
return backend.KerasTensor(
100+
inputs.shape, dtype=inputs.dtype, sparse=inputs.sparse
105101
)
106102

107103
def transform_bounding_boxes(self, bounding_boxes, **kwargs):

0 commit comments

Comments
 (0)