Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Efficient way to extract pool_3 for large number of images?

Tags:

tensorflow

I'd like to use pool_3 features extracted from a set of images. Currently I have a loop over each image to extract the pool_3 features:

# X_input.shape = (40000, 32, 32, 3)
def batch_pool3_features(X_input):
    sess = tf.InteractiveSession()
    n_train = X_input.shape[0]
    print 'Extracting features for %i rows' % n_train
    pool3 = sess.graph.get_tensor_by_name('pool_3:0')
    X_pool3 = []
    for i in range(n_train):
        print 'Iteration %i' % i
        pool3_features = sess.run(pool3,{'DecodeJpeg:0': X_input[i,:]})
        X_pool3.append(np.squeeze(pool3_features))
    return np.array(X_pool3)

This is quite slow though. Is there a faster batch implementation to do this?

Thanks

like image 441
sthomps Avatar asked Dec 04 '25 15:12

sthomps


1 Answers

It doesn't - yet. I've opened a ticket for this feature request on github in response to another question.

like image 178
dga Avatar answered Dec 06 '25 08:12

dga