Tensorflow - Load pre-trained inception_v3 to use with tf.estimator

525 Views Asked by At

I am using tf.estimator.Estimator to train my model. I would now like to try a pre-trained inception_v3 in place of my current model.

I stumbled upon this repository that seems to have all the models I could ever need: https://github.com/tensorflow/models/tree/master/research/slim

Loading the graph and training seems to work just fine. Now it would also like to use the pre-trained weights that I downloaded from here: http://download.tensorflow.org/models/inception_v3_2016_08_28.tar.gz

I tried multiple variants that I found online, but nothing seems to work thus far. Most of the time I am getting the following error:

Tensor name "model/InceptionV3/AuxLogits/Conv2d_1b_1x1/BatchNorm/beta" not found in checkpoint files

This is how I build the graph right now:

sys.path.insert(0, "./models/research/slim")
from nets import nets_factory

# ...

params.network_name = "inception_v3",
params.pre_logits   = "PreLogits",         
params.checkpoint   = "inception_v3.ckpt"

# ...

network_fn = nets_factory.get_network_fn(params.network_name,
                                         num_classes=(1001),
                                         weight_decay=0.00004,
                                         is_training=is_training)

logits, end_points = network_fn(images)        

pre_logits = end_points[params.pre_logits]
pre_logits = tf.layers.flatten(inputs=pre_logits)

# ...

loss = ...

train_op = optimizer.minimize(loss, global_step=global_step)
model_fn = tf.estimator.EstimatorSpec(mode, loss=loss, train_op=train_op)

estimator = tf.estimator.Estimator(model_fn, 
                                   params=params, 
                                   config=config)

# ...

I tried tensorflow versions v.1.6.0 and v.1.8.0. Both seem to have the same issues.

Any ideas?

Thank you very much!

0

There are 0 best solutions below