# 需要导入模块: from keras import layers [as 别名]
# 或者: from keras.layers import Subtract [as 别名]
def get_Discriminator(input_shape_1, input_shape_2, Encoder):
dis_inputs_1 = Input(shape=input_shape_1) # Image
dis_inputs_2 = Input(shape=input_shape_2) # Segmentation
mul_1 = Multiply()([dis_inputs_1, dis_inputs_2]) # Getting segmented part
encoder_output_1 = Encoder(dis_inputs_1)
encoder_output_2 = Encoder(mul_1)
subtract_dis = Subtract()([encoder_output_1, encoder_output_2])
dis_conv_block = Conv3D(128, (3, 3, 3), strides=(1, 1, 1), padding='same')(subtract_dis)
dis_conv_block = Activation('relu')(dis_conv_block)
dis_conv_block = Conv3D(128, (3, 3, 3), strides=(1, 1, 1), padding='same')(dis_conv_block)
dis_conv_block = Activation('relu')(dis_conv_block)
dis_conv_block = MaxPooling3D(pool_size=(2, 2, 2), strides=(2, 2, 2))(dis_conv_block)
dis_conv_block = Conv3D(64, (3, 3, 3), strides=(1, 1, 1), padding='same')(dis_conv_block)
dis_conv_block = Activation('relu')(dis_conv_block)
dis_conv_block = Conv3D(64, (3, 3, 3), strides=(1, 1, 1), padding='same')(dis_conv_block)
dis_conv_block = Activation('relu')(dis_conv_block)
dis_conv_block = Conv3D(32, (3, 3, 3), strides=(1, 1, 1), padding='same')(dis_conv_block)
dis_conv_block = Activation('relu')(dis_conv_block)
dis_conv_block = Conv3D(32, (3, 3, 3), strides=(1, 1, 1), padding='same')(dis_conv_block)
dis_conv_block = Activation('relu')(dis_conv_block)
flat_1 = Flatten()(dis_conv_block)
dis_fc_1 = Dense(256)(flat_1)
dis_fc_1 = Activation('relu')(dis_fc_1)
dis_drp_1 = Dropout(0.5)(dis_fc_1)
dis_fc_2 = Dense(128)(dis_drp_1)
dis_fc_2 = Activation('relu')(dis_fc_2)
dis_drp_2 = Dropout(0.5)(dis_fc_2)
dis_fc_3 = Dense(1)(dis_drp_2)
dis_similarity_output = Activation('sigmoid')(dis_fc_3)
Discriminator = Model(inputs=[dis_inputs_1, dis_inputs_2], outputs=dis_similarity_output)
Discriminator.compile(optimizer=Adadelta(lr=0.01), loss='binary_crossentropy', metrics=['accuracy'])
print('Discriminator Architecture:')
print(Discriminator.summary())
return Discriminator