Keras:模型的输入张量必须来自keras.layers.Input`

时间:2019-10-27 17:07:15

标签: python tensorflow keras

我正在尝试合并先前训练过的两个模型的某些层输出。以前,我已经使用以下代码成功使用了中间层的输出:

intermediate_layer_model = Model(inputs=audio.model.input,
                                     outputs=audio.model.get_layer(layer_name).output)

但是对于我的新模型,以下代码失败:

combined_model = Model(inputs=[audio.model.input, visual.model.input], outputs=loss_out)

具有以下跟踪信息:

Traceback (most recent call last):
  File "multimodalTrain1.py", line 191, in <module>
    train(run_name, 0, 300, 1, 100, 50, 75, 34, 64)
  File "multimodalTrain1.py", line 154, in train
    outputs=loss_out)
  File "/srv/users/Rifqi/avid/lib/python3.5/site-packages/keras/legacy/interfaces.py", line 91, in wrapper
    return func(*args, **kwargs)
  File "/srv/users/Rifqi/avid/lib/python3.5/site-packages/keras/engine/network.py", line 94, in __init__
    self._init_graph_network(*args, **kwargs)
  File "/srv/users/Rifqi/avid/lib/python3.5/site-packages/keras/engine/network.py", line 169, in _init_graph_network
    ' (missing previous layer metadata).')
ValueError: Input tensors to a Model must come from `keras.layers.Input`. Received: [<tf.Tensor 'the_input:0' shape=(?, 190, 96, 1) dtype=float32>, <tf.Tensor 'the_labels:0' shape=(?, 34) dtype=int32>, <tf.Tensor 'input_length:0' shape=(?, 1) dtype=int32>, <tf.Tensor 'label_length:0' shape=(?, 1) dtype=int32>] (missing previous layer metadata).

P.S。每个模型都接受多个输入

0 个答案:

没有答案