代码之家  ›  专栏  ›  技术社区  ›  hanen balti

用TensorFlow从我自己的数据中用VGNET提取特征?

  •  -2
  • hanen balti  · 技术社区  · 7 年前

    有人能帮我吗? 谢谢

    2 回复  |  直到 7 年前
        1
  •  0
  •   T. Kelher    7 年前

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

    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
  •  0
  •   hanen balti    7 年前

    我通过将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)
    
    推荐文章