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)
....
在尝试构建并行模型时,我会这样做
a_model = models.Model([my_layer.tensor_a],[my_layer.c])
我找不到任何解决这个问题的好办法?如何将张量转换为K.tensor
?