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
Asked
Active
Viewed 212 times
2 Answers
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
-
Thank you, your solution is helpful – hanen balti Nov 30 '18 at 13:48
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)

hanen balti
- 31
- 5