Python 使用TensorFlow从我自己的数据中使用VGGnet提取特征?

Python 使用TensorFlow从我自己的数据中使用VGGnet提取特征?,python,tensorflow,deep-learning,vgg-net,Python,Tensorflow,Deep Learning,Vgg Net,我用SIRI-WHU数据集预先训练了VGG19,现在我想提取特征,但我不知道怎么做。 有人能帮我吗? 谢谢没有多少信息可以帮助你。可以加载模型吗?如果可以,可以执行以下操作: 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")

我用SIRI-WHU数据集预先训练了VGG19,现在我想提取特征,但我不知道怎么做。 有人能帮我吗?
谢谢

没有多少信息可以帮助你。可以加载模型吗?如果可以,可以执行以下操作:

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 **})

这段代码假设您的图形在内存中,如果您在执行此操作时遇到问题,请询问

我通过将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)

谢谢,您的解决方案很有帮助