Skip to content

Commit 90a845f

Browse files
author
roebel
committed
Removed unused part of the code. The code in the fix should deal exclusively with the case that is not properly handled by ops.reshape. This is when the batch dimension does not have a static shape (shape == None) but all other dimensions have static shape. In that case we can determine the static shape of the dimension containing -1 form all dimensions that are not the batch dimension.
1 parent bc45bcc commit 90a845f

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

keras/src/layers/reshaping/reshape.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,7 @@ def call(self, inputs):
7070
if self.need_explicit_shape_for_batch_size_None and (inputs.shape[0] is None):
7171
input_nonbatch_shape = tuple(inputs.shape[1:])
7272
if input_nonbatch_shape.count(None) == 0:
73-
# If the input shape is fully defined, we can compute the desired target_shape
74-
if True:
75-
inp_nonbatch_size = math.prod(inputs.shape[1:])
76-
else:
77-
inp_nonbatch_size = ops.prod(ops.shape(inputs)[1:])
73+
inp_nonbatch_size = math.prod(inputs.shape[1:])
7874
target_shape = tuple(d if d != -1 else (inp_nonbatch_size // self.new_size_no_minus_one) for d in self.target_shape)
7975

8076
return ops.reshape(

0 commit comments

Comments
 (0)