-2

I pre-trained VGG19 with SIRI-WHU dataset, and now I want to extract the features, and I don't know how to do it. Can someone help me please? thanks

Armali
  • 18,255
  • 14
  • 57
  • 171

2 Answers2

0

Well there is not much information to help you. Can you load the model, if so you can do something like this:

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

This code assumes that your graph is in memory, if you've problems doing that, just ask

T. Kelher
  • 1,188
  • 10
  • 9
0

I solved this issue by fixing the FC6 layer as an output layer

prob = sess.run(vgg.fc6, feed_dict=feed_dict)

then I stored the features in h5 file

f = h5py.File('sample.h5','a')
f.create_dataset('data',data=prob,dtype=np.float32)