jrabary February 2016

InceptionV3 and transfer learning with tensorflow

I would like to do a transfer learning from the given inceptionV3 in tensorflow example. Following the classify image example and the operator and tensor names given here https://github.com/AKSHAYUBHAT/VisualSearchServer/blob/master/notebooks/notebook_network.ipynb I can create my graph. But when, I put a batch of images of size (100, 299, 299, 3) in the pre-computed inception graph, I get the following shape error at the pool_3 layer :

ValueError: Cannot reshape a tensor with 204800 elements to shape [1, 2048] (2048 elements)

It seems that this inceptionV3 graph doesn't accept image batch as input. am I wrong ?

Answers


dga February 2016

You're not wrong. This seems like a very reasonable feature request, so I've opened a ticket for it on github. Follow that for updates.


etarion February 2016

Actually it works for transfer learning if you extract the right thing. There is no problem feeding a batch of images in the shape of [N, 299, 299, 3] as ResizeBilinear:0 and then using the pool_3:0 tensor. It's the reshaping afterwards that breaks, but you can reshape yourself (you'll have your own layers afterwards anyway). If you wanted to use the original classifier with a batch, you could add your own reshaping on top of pool_3:0 and then add the softmax layer, reusing the weights/biases tensors of the original softmax.

TLDR: With double_img being a stack of two images with shape (2, 299, 299, 3) this works:

pooled_2 = sess.graph.get_tensor_by_name("pool_3:0").eval(session=sess, feed_dict={'ResizeBilinear:0':double_img})
pooled_2.shape
# => (2, 1, 1, 2048)

Post Status

Asked in February 2016
Viewed 2,256 times
Voted 12
Answered 2 times

Search




Leave an answer