Refactor internal keras code to remove deprecated call to tf.concat() with scalars.
@@ -3833,6 +3833,9 @@ def concat(tensors, axis=0):
"""Concats `tensor`s along `axis`."""
if isinstance(tensors[0], tf.SparseTensor):
return tf.sparse.concat(axis=axis, sp_inputs=tensors)
+ elif _is_scalar(tensors[0]):
+ return tf.stack(tensors, axis=axis)
+ else:
return tf.concat(tensors, axis=axis)
@@ -3861,6 +3864,9 @@ def potentially_ragged_concat(tensors):
)
if tf.math.reduce_all(constant_dims).numpy().item():
# All non-batch dims are constant
+ if _is_scalar(tensors[0]):
+ return tf.stack(tensors, axis=0)
+ else:
return tf.concat(tensors, axis=0)
# First, identify constant inner dimensions by finding the
