我正在尝试采用 KerasInfoGAN
实现来从本质上提取我提供给鉴别器的图像的传输值(或嵌入)。有了这个,我想对结果向量执行相似性搜索,以找到与数据集中提供的图像最相似的 n 个图像。
我想使用 Keras,所以我将这个实现作为参考:
我发现了这个 TensorFlow 0.11
实现,它们提供了实现相似性目标的功能,但是我在尝试在 Keras 中完成类似的事情时遇到了麻烦。
我想更简单地说,我想了解哪个层最适合从鉴别器中获取传输值,以及如何在 Keras 中使用经过训练的模型来做到这一点。鉴别器层:
x = Convolution2D(64, (4, 4), strides=(2,2))(self.d_input)
x = LeakyReLU(0.1)(x)
x = Convolution2D(128, (4, 4), strides=(2,2))(x)
x = LeakyReLU(0.1)(x)
x = BatchNormalization()(x)
x = Flatten()(x)
x = Dense(1024)(x)
x = LeakyReLU(0.1)(x)
self.d_hidden = BatchNormalization()(x) # Store this to set up Q
self.d_output = Dense(1, activation='sigmoid', name='d_output')(self.d_hidden)
self.discriminator = Model(inputs=[self.d_input], outputs=[self.d_output], name='dis_model')
self.opt_discriminator = Adam(lr=2e-4)
self.discriminator.compile(loss='binary_crossentropy',
optimizer=self.opt_discriminator)