我正在使用 Keras 为 224x224x3 大小的图像开发一个用于人脸识别的连体网络。Siamese Network 的架构是这样的:
对于 CNN 模型,我正在考虑使用已经在 Keras.applications 模块中预训练的 InceptionV3 模型。
#Assume all the other modules are imported correctly
from keras.applications.inception_v3 import InceptionV3
IMG_SHAPE=(224,224,3)
def return_siamese_net():
left_input=Input(IMG_SHAPE)
right_input=Input(IMG_SHAPE)
model1=InceptionV3(include_top=False, weights="imagenet", input_tensor=left_input) #Left SubConvNet
model2=InceptionV3(include_top=False, weights="imagenet", input_tensor=right_input) #Right SubConvNet
#Do Something here
distance_layer = #Do Something
prediction = Dense(1,activation='sigmoid')(distance_layer) # Outputs 1 if the images match and 0 if it does not
siamese_net = #Do Something
return siamese_net
model=return_siamese_net()
由于模型是预训练的,我得到了错误,我现在被困在为孪生网络实现距离层。
为了使这个连体网络正常工作,我应该在两者之间添加什么?