【问题标题】:Feature extraction with VGGnet from my own data with TensorFlow?使用 TensorFlow 从我自己的数据中使用 VGGnet 进行特征提取?
【发布时间】:2018-11-04 16:55:11
【问题描述】:

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

【问题讨论】:

    标签: python tensorflow deep-learning vgg-net


    【解决方案1】:

    没有太多信息可以帮助您。你能加载模型吗,如果可以的话,你可以这样做:

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

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

    【讨论】:

    • 谢谢,您的解决方案很有帮助
    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 2019-06-07
      • 2020-08-06
      • 2012-10-19
      • 1970-01-01
      • 2020-11-13
      • 1970-01-01
      • 2016-03-14
      • 2017-07-10
      • 1970-01-01
      相关资源
      最近更新 更多