我用SIRI-WHU数据集预训练了VGG19,现在想提取特征,不知道怎么做。有人能帮助我吗?谢谢
问问题
187 次
2 回答
0
好吧,没有太多信息可以帮助您。您可以加载模型吗,如果可以,您可以执行以下操作:
with tf.Session() as sess:
# the tensor you want to feed your image to
input_tensor = sess.graph.get_tensor_by_name("name of your input tensor")
# the tensor you're interested in, most likely last_dense_layer_name/BiasAdd:0
output_tensor = sess.graph.get_tensor_by_name("name of your output tensor")
feature_vector = sess.run(output_tensor, feed_dict={input_tensor: **insert numpy array of your image **})
此代码假定您的图表在内存中,如果您在执行此操作时遇到问题,请询问
于 2018-11-04T23:07:13.490 回答
0
我通过将 FC6 层固定为输出层解决了这个问题
prob = sess.run(vgg.fc6, feed_dict=feed_dict)
然后我将特征存储在 h5 文件中
f = h5py.File('sample.h5','a')
f.create_dataset('data',data=prob,dtype=np.float32)
于 2018-11-30T13:42:56.770 回答