模型的输入张量必须是Keras张量

模型的输入张量必须是Keras张量,keras,keras-layer,Keras,Keras Layer,嗨,我在尝试将一层的中间变量用作并行网络的输入时遇到了这个错误。这样,一层的中间变量将被输入到另一个网络 Input tensors to a Model must be Keras tensors. Found: Tensor("my_layer/Identity:0", shape=(?, 10, 1152, 16), dtype=float32) (missing Keras metadata). 在尝试构建并行模型时,我会这样做 def call(self, inputs, trai

嗨,我在尝试将一层的中间变量用作并行网络的输入时遇到了这个错误。这样,一层的中间变量将被输入到另一个网络

Input tensors to a Model must be Keras tensors. Found:
Tensor("my_layer/Identity:0", shape=(?, 10, 1152, 16), dtype=float32)
(missing Keras metadata).
在尝试构建并行模型时,我会这样做

def call(self, inputs,  training=None):
    inputs_expand = K.expand_dims(inputs, 1)
    tensor_b = K.tile(inputs_expand, [1, 16, 1, 1])
    tensor_a = K.map_fn(lambda x: K.batch_dot(x, self.Weights, [2, 3]), elems=tensor_b)
    # I need this tensor_a
    # I tried many things but ended putting it to member variable.
    self.tensor_a = K.identity(inputs_hat)
    ....
我找不到解决这个问题的好办法?如何将张量转换为K张量

a_model = models.Model([my_layer.tensor_a],[my_layer.c])