孪生网络显示 ValueError

Siamese network showing ValueError

我将 Siamese 网络用于具有不同域的 2000 个功能。我想训练相似的特征对并测试不同的特征对。我在尝试拟合模型时遇到值错误。

def get_siamese_conv_unit(input):
    encoder = models.Sequential(name='encoder')
    encoder.add(layer=layers.Dense(units=64, activation=activations.relu))
    encoder.add(layers.Dropout(0.1))
    encoder.add(layer=layers.Dense(units= 32, activation=activations.relu))
    encoder.add(layers.Flatten())
    encoder.summary()
    return encoder
def get_classifier_model(input_shape):
    left_input = Input(input_shape)
    right_input = Input(input_shape)
    model = get_siamese_conv_unit(input_shape)
    encoded_l = model(left_input)
    encoded_r = model(right_input)
    L1_layer = Lambda(lambda tensors:k.backend.abs(tensors[0] - tensors[1]))
    L1_distance = L1_layer([encoded_l, encoded_r])
    prediction = Dense(1,activation='sigmoid',bias_initializer=initialize_bias)(L1_distance)
    siamese_net = Model(inputs=[left_input,right_input],outputs=prediction)
    return siamese_net

 # After optimization
model.fit([left_input, right_input] ,target , epochs=100, verbose=1,validation_data=[test1, test2])

我收到以下错误

Error when checking model input: the list of Numpy arrays that you are passing to your model is not the size the model expected. 
Expected to see 2 array(s), for inputs ['input_17', 'input_18'] 
but instead got the following list of 1 arrays

left_input,right_input和target的类型都是数组

我已通过在拟合时添加测试标签来纠正我的错误:

model.fit([left_input, right_input] ,target , epochs=100, verbose=1,validation_data=([test1, test2],ytest))