如何查看Keras中concatenate的功能?

How to view the functionality of concatenate in Keras?

我正在查看 keras 合并层 (https://keras.io/layers/merge/),并想了解每个层操作执行的操作。我想它们的功能相当直观,但我想弄清楚如何查看给定示例的输出。

为了说明我的意思,我有两个随机输入形状为 (1,10) 的数组,我想看看如果我将这两个数组连接起来,输出会是什么。但是,当我执行以下操作时,出现以下错误:Layer concatenate_18 was called with an input that isn't a symbolic tensor. Received type: <class 'numpy.ndarray'>...All inputs to the layer should be tensors.

from keras.layers import concatenate
data1 = np.random.normal(0, 1, size = (1, 10))
data2 = np.random.normal(0, 1, size = (1, 10))
concatenation = concatenate([data1, data2])
print(concatenation) # I want to print the output of concatenating data1 and data2

根据消息,我假设此错误与输入是 numpy 数组这一事实有关,但我不确定应该采用什么格式?如何查看在示例中使用 concatenate 的输出?谢谢!

我想我知道怎么做了。我使用的数据与我上面描述的不同,但应该实现相同的行为。看起来我需要指定输入张量、实例化模型并对数据调用预测。

input1 = Input(shape=(3,))
input2 = Input(shape=(3,))
merge = concatenate([input1, input2])
model = Model([input1, input2], merge)

a = np.array([[1,1,1]])
b = np.array([[1,1,1]])
model.predict([a,b])