Source code
build_model
build_image_embeddings
在建立了图片和caption的输入后,这部分将图片转换为固定大小的tensor,就像论文提及的,使用已经用很大的数据集训练好的深度网络模型,不改变它的参数,直接用于特征提取。
首先将图片丢入inception v3网络中,得到输出,代码如下:
inception_output = image_embedding.inception_v3(
self.images,
trainable=self.train_inception,
is_training=self.is_training())
这里我们先来看一下inception v3这个模型。inception model
“Rethinking the Inception Architecture for Computer Vision”slim包中提供的inception_v3函数直接返回论文中提到的模型。
Map inception output into embedding space.
这里直接用inception的输出作为图片的特征,并且通过一个全联接层,作为embedding。
with tf.variable_scope("image_embedding") as scope:
image_embeddings = tf.contrib