【发布时间】:2018-01-04 23:13:45
【问题描述】:
我正在尝试在 tensorflow 中训练神经网络。我使用 tf.train.batch_join() 函数加载数据及其标签。我做这样的事情:
image_batch, label_batch, image_batch_f = tf.train.batch_join(
images_and_labels, batch_size=batch_size_placeholder,
#shapes=[(args.image_size, args.image_size, 3), ()], enqueue_many=True,
shapes=[(args.image_height, args.image_width, 3), (), (args.image_height, args.image_width, 3)], enqueue_many=True,
capacity=4 * nrof_preprocess_threads * args.batch_size,
allow_smaller_final_batch=True)
image_batch = tf.identity(image_batch, 'image_batch')
image_batch = tf.identity(image_batch, 'input')
label_batch = tf.identity(label_batch, 'label_batch')
image_batch_f = tf.identity(image_batch_f, 'flipped_images_batch')
在这里,我得到三批数据。一批图像、一批标签和一批与该批图像中相同的图像的翻转图像。我想在这批图像和翻转图像上提取特征。下面的行通过网络传递批量数据。
# Build the inference graph
prelogits, _ = network.inference(image_batch, args.keep_probability,
phase_train=phase_train_placeholder, feature_dimension=args.embedding_size,
weight_decay=args.weight_decay)
features = tf.nn.l2_normalize(prelogits, 1, 1e-10, name='embeddings')
#getting the flipped embeddings
prelogits_f, _ = network.inference(image_batch_f,args.keep_probability,
phase_train=phase_train_placeholder,feature_dimension=args.embedding_size,
weight_decay=args.weight_decay,reuse=True)
features_flipped_images = tf.nn.l2_normalize(prelogits_f,1,1e-10,name='embeddings_f')
为了获得这两个功能,我在 features 和 features_flipped_images 操作上运行了 session.run()。像这样的:
feed_dict = {phase_train_placeholder:False, batch_size_placeholder:batch_size}
emb, emb_f = sess.run([features, features_flipped_images],feed_dict=feed_dict)
我的问题如下。我猜当我在功能上运行会话时,即 batch_join 函数将分派一批大小为 batch_size 的图像。但是当我对 features_flipped_images 执行 session.run() 时,该函数还将从 batch_join 函数中获取一批翻转的图像。执行 features_flipped_images 时,batch_join 函数是否会分派一批新的翻转图像?还是执行特征时生成的同一批翻转图像?如果没有,那么我该怎么做?我想在这批图像和一批翻转图像上提取特征。
【问题讨论】: