【发布时间】:2016-10-09 23:30:29
【问题描述】:
我正在尝试在 cifar-10 数据集上训练一个网络,但我不想使用图片,而是使用 Inceptions 在最后一层之前的特征。
于是我写了一个小平安pf代码来传递Inception中的所有图片并获取特征,这里是:
def run_inference_on_images(images):
#Creates graph from saved GraphDef.
create_graph()
features_vec = np.ndarray(shape=(len(images),2048),dtype=np.float32)
with tf.Session() as sess:
# Some useful tensors:
# 'pool_3:0': A tensor containing the next-to-last layer containing 2048
# float description of the image.
# 'DecodeJpeg:0': A numpy array of the image
# Runs the softmax tensor by feeding the image data as input to the graph.
length = len(images)
for i in range(length):
print ('inferencing image number',i,'out of', length)
features_tensor = sess.graph.get_tensor_by_name('pool_3:0')
features = sess.run(features_tensor,
{'DecodeJpeg:0': images[i]})
features_vec[i] = np.squeeze(features)
return features_vec
“图像”是 CIFAR-10 数据集。这是一个形状为 (50000,32,32,3) 的 numpy 数组
我面临的问题是,即使我将不同的图片提供给“sess.run”部分,“特征”输出总是相同的。 我错过了什么吗?
【问题讨论】:
标签: python tensorflow deep-learning