I'm using Siamese network for 2000 features with different domains. I want to train on similar pairs and test on dissimilar pair of features. I'm encountering value error when I try to fit the model.
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])
I get the following error
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
The type of left_input ,right_input and target are all arrays
I have rectified my error by adding test labels while fitting:
model.fit([left_input, right_input] ,target , epochs=100, verbose=1,validation_data=([test1, test2],ytest))