【发布时间】:2020-09-03 10:13:33
【问题描述】:
我正在尝试加载预训练的嵌入模型,但无论我给出什么形状,我都找不到输入形状。这似乎是一个非常受欢迎的选择,但我在 tensorflow 中心页面上找不到任何关于使用什么输入形状的指标。输入序列应该具有可变长度,因此我使用无输入形状。 Keras 自动提供批量大小
embedding_url = 'https://tfhub.dev/google/universal-sentence-encoder-large/5'
embedding_layer = hub.KerasLayer(embedding_url)
premises = tf.keras.Input(shape=(None,))
conclusion = tf.keras.Input(shape=(None,))
x1 = embedding_layer(premises)
x2 = embedding_layer(conclusion)
model = tf.keras.Model(inputs=[premises, conclusion], outputs=[x1, x2])
这是我得到的错误
ValueError: Python inputs incompatible with input_signature:
inputs: (
Tensor("input_5:0", shape=(None, None), dtype=float32))
input_signature: (
TensorSpec(shape=<unknown>, dtype=tf.string, name=None))
【问题讨论】:
标签: python tensorflow keras