【发布时间】:2019-03-31 17:06:51
【问题描述】:
我正在尝试合并两个模型的输出,并使用 keras 顺序模型将它们作为输入提供给第三个模型。 模型1:
inputs1 = Input(shape=(750,))
x = Dense(500, activation='relu')(inputs1)
x = Dense(100, activation='relu')(x)
模型1:
inputs2 = Input(shape=(750,))
y = Dense(500, activation='relu')(inputs2)
y = Dense(100, activation='relu')(y)
模型3:
merged = Concatenate([x, y])
final_model = Sequential()
final_model.add(merged)
final_model.add(Dense(100, activation='relu'))
final_model.add(Dense(3, activation='softmax'))
直到这里,我的理解是,来自两个模型的输出,如 x 和 y 被合并并作为输入给第三个模型。但是当我适合这一切时,
module3.compile(optimizer='rmsprop', loss='categorical_crossentropy', metrics=['accuracy'])
module3.fit([in1, in2], np_res_array)
in1 和 in2 是两个尺寸为 10000*750 的 numpy ndarray,其中包含我的训练数据,而 np_res_array 是相应的目标。
这给了我错误,因为 'list' 对象没有属性 'shape' 据了解,这就是我们给模型提供多个输入的方式,但是这个错误是什么?我该如何解决?
【问题讨论】:
-
为未来的读者(我也是)。我假设 in1 和 inputs1 以及 module3 和 final_model 相同。对吗?
标签: python tensorflow keras sequential