我用多个输入和单个输出创建了 NN 。我的简单网络对每个观察都有3个输入节点,在隐藏层(中间)只有一个节点。之后,我将它们串联起来。最后,有一个单个输出,其节点数与输入节点数相同。
num_vars_per_input = 3
num_single_inputs = 2
num_middle_units = 1
output_shape= num_single_inputs
single_input_shape = (num_vars_per_input,)
input_layers = [keras.Input(shape=single_input_shape) for _ in range(num_single_inputs)]
middle_layer = layers.Dense(num_middle_units)
middle_layers_outs = []
for i,inp in enumerate(input_layers):
middle_layers_outs.append(middle_layer(inp))
middle_layer_concat_out = Concatenate()(middle_layers_outs)
output_layer = Dense(num_single_inputs ,activation="softmax")
output_layer_out = output_layer(middle_layer_concat_out)
model = keras.Model(inputs = input_layers, outputs = output_layer_out,name= "player")
model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
#Prediction:
#Data
x = np.array([[90., 89., 91.],[68., 61., 73.]])
model.predict(x)
**ERROR**:
AssertionError: Could not compute output Tensor("dense_59/Softmax:0", shape=(None, 2), dtype=float32)
有什么错误?该部分之后的连接方法或形状?