Cannot take the length of Shape with unknown rank

Could you post a longer stack-trace? I think your problem might be related to this recent tensorflow issue:

https://github.com/tensorflow/tensorflow/issues/24520

There's also a simple PR that fixes it (not yet merged). Maybe try it out yourself?

EDIT

Here is the PR: open tensorflow/python/keras/engine/training_utils.py

replace the following (line 232 at the moment):

  if (x.shape is not None
      and len(x.shape) == 1

with this:

  if tensor_util.is_tensor(x):
    x_shape_ndims = x.shape.ndims if x.shape is not None else None
  else:
    x_shape_ndims = len(x.shape)

  if (x_shape_ndims == 1