Я пытаюсь объединить две модели в кератах, но получаю сообщение об ошибке
вот две модели
1. `image_model = Sequential([
Dense(embedding_size, input_shape=(2048,), activation='relu'),
RepeatVector(max_len)
])`
2.` caption_model = Sequential([
Embedding(vocab_size, embedding_size, input_length=max_len),
LSTM(256, return_sequences=True),
TimeDistributed(Dense(300))
])`
моя функция конкатенации - сама "конкатенация", поскольку мы не можем использовать слияниев Керас-2.0, поэтому я использовал его.
3. `final_model = Sequential([
concatenate([image_model, caption_model],axis=-1),
Bidirectional(LSTM(256, return_sequences=False)),
Dense(vocab_size),
Activation('softmax')
]) `
Но вот ошибка, которую я получаю, как ее решить, я нашел ее, но ни одно из решений не помогло мне.пожалуйста помогите
~/anaconda3/lib/python3.6/site-packages/keras/engine/base_layer.py in
assert_input_compatibility(self, inputs)
278 try:
279 K.is_keras_tensor(x)
280 except ValueError:
~/anaconda3/lib/python3.6/site-
packages/keras/backend/tensorflow_backend.py in is_keras_tensor(x)
471 raise ValueError('Unexpectedly found an instance
ofstr(type(x)) + '`. '
473 'Expected a symbolic tensor instance.')
ValueError: Unexpectedly found an instance of type `<class
'keras.engine.sequential.Sequential'>`. Expected a symbolic tensor
instance.
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call
last)
<ipython-input-107-04c9412f6b6d> in <module>
5
6 final_model = Sequential([
7 concatenate([image_model, caption_model],axis=-1),
8 Bidirectional(LSTM(256, return_sequences=False)),
9 Dense(vocab_size),
~/anaconda3/lib/python3.6/site-packages/keras/layers/merge.py in
concatenate(inputs, axis, **kwargs)
639 A tensor, the concatenation of the inputs alongside axis
`axis`.
640 """
--> 641 return Concatenate(axis=axis, **kwargs)(inputs)
642
643
~/anaconda3/lib/python3.6/site-packages/keras/engine/base_layer.py
in __call__(self, inputs, **kwargs)
412 # Raise exceptions in case the input is not
compatible
413 # with the input_spec specified in the layer
constructor.
--> 414 self.assert_input_compatibility(inputs)
415
416 # Collect input shapes to build layer.
~/anaconda3/lib/python3.6/site-packages/keras/engine/base_layer.py
in assert_input_compatibility(self, inputs)
283 'Received type: ' +
284 str(type(x)) + '. Full input:
' +
--> 285 str(inputs) + '. All inputs
to the layer '
286 'should be tensors.')
287
ValueError: Layer concatenate_16 was called with an input that
isn't a symbolic tensor. Received type: <class
keras.engine.sequential.Sequential'>. Full input:
[<keras.engine.sequential.Sequential object at 0x7f63ae5b8240>,
<keras.engine.sequential.Sequential object at 0x7f63ae592320>].
All inputs to the layer should be tensors.