如何在Tensorflow 2.2中训练具有多个输入的Keras模型?

I'd like to train a Keras model with two inputs (one text input and some numerical features), but I struggle to get it working. I've setup a model as described in the Tensorflow documentation about models with multiple inputs:

import tensorflow as tf
from tensorflow.keras import Input, Model, models, layers


def build_model():
    input1 = Input(shape=(50,), dtype=tf.int32, name='x1')
    input2 = Input(shape=(1,), dtype=tf.float32, name='x2')
    y1 = layers.Embedding(1000, 10, input_length=50)(input1)
    y1 = layers.Flatten()(y1)
    y = layers.Concatenate(axis=1)([y1, input2])
    y = layers.Dense(1)(y)
    return Model(inputs=[input1, input2], outputs=y)

构建该模型也可以正常工作:

model = build_model()
model.compile(loss='mse')
model.summary()

You can find the output of summary() in this gist.

然后需要一些(虚拟)数据来拟合模型:

def make_dummy_data():
    X1 = tf.data.Dataset.from_tensor_slices(tf.random.uniform([100, 50], maxval=1000, dtype=tf.int32))
    X2 = tf.data.Dataset.from_tensor_slices(tf.random.uniform([100, 1], dtype=tf.float32))
    X = tf.data.Dataset.zip((X1, X2)).map(lambda x1, x2: {'x1': x1, 'x2': x2})
    y_true = tf.data.Dataset.from_tensor_slices(tf.random.uniform([100, 1], dtype=tf.float32))
    return X, y_true


X, y_true = make_dummy_data()
Xy = tf.data.Dataset.zip((X, y_true))
model.fit(Xy, batch_size=32)

...but now fit() fails with an incomprehensible error message (see full message here), which starts with a (probably relevant) warning:

WARNING:tensorflow:Model was constructed with shape (None, 50) for input Tensor("x1:0", shape=(None, 50), dtype=int32), but it was called on an input with incompatible shape (50, 1).

呵呵,尺寸1的额外维度是从哪里来的?而且,我该如何摆脱呢?

One more thing: further simplification of this dummy model by removing the Embedding-layer does suddenly make the model run.

If you want to play around with the above sample, I prepared a notebook on Google Colab for it. Any help appreciated.