tensorflow,keras,模型的输出张量必须是tensorflow`层的输出`
带有tensorflow,keras,模型的输出张量必须是tensorflow`层的输出`,tensorflow,keras,Tensorflow,Keras,带有ValueError的第一个模型错误:模型的输出张量必须是TensorFlow层的输出(因此保存过去的层元数据)。发现:张量(“稠密/BiasAdd:0”,形状=(?,1,1),dtype=float32) 然而,第二个是有效的,我不理解错误的含义 def get_model():
ValueError的第一个模型错误:模型的输出张量必须是TensorFlow
层的输出(因此保存过去的层元数据)。发现:张量(“稠密/BiasAdd:0”,形状=(?,1,1),dtype=float32)
然而,第二个是有效的,我不理解错误的含义
def get_model():
first_input = Input(shape = (1,), name='first_input')
second_input = Input(shape = (5,), name='second_input' )
embedding_layer = Embedding(input_dim=10, output_dim=3, input_length=1)
first_input_encoded = embedding_layer(first_input)
second_input_encoded = embedding_layer(second_input)
second = tf.reduce_mean(second_input_encoded, axis=1, keepdims=True)
o = concatenate([first_input_encoded, second])
o = Dense(1)(o)
model = tf.keras.models.Model(inputs=[first_input, second_input], outputs=o)
return model
请给我们看看你们正在进口的商品using@MatiasValdenegro添加了导入您应该在第一个模型中使用
second\u input
而不是second\u input\u encoded
。我无法重现你的问题。请给我们看看你的进口产品using@MatiasValdenegro添加了导入您应该在第一个模型中使用second\u input
而不是second\u input\u encoded
。我无法重现你的问题。
def get_model():
first_input = Input(shape = (1,), name='first_input')
second_input = Input(shape = (5,), name='second_input' )
embedding_layer = Embedding(input_dim=10, output_dim=3, input_length=1)
first_input_encoded = embedding_layer(first_input)
second_input_encoded = embedding_layer(second_input)
second = tf.reduce_mean(second_input_encoded, axis=1, keepdims=True)
o = concatenate([first_input_encoded, second])
o = Dense(1)(o)
model = tf.keras.models.Model(inputs=[first_input, second_input], outputs=o)
return model