Skip to content Skip to sidebar Skip to footer

How To Restore Tensorflow V1.1.0 Saved Model In V1.13.1

I'm trying to restore the pretrained model provided here and continue training on a different dataset. The pretrained models available there are trained on tensorflow_gpu-1.1.0. Bu

Solution 1:

I am really not sure if it is possible to port a model but I will try to share how I solved this issue.

First off, you should be able to create whole graph independent of the TensorFlow version. If any error occurs there it should be a minimal one. Then, you can simply copy all variables from your old model to the new one with:

RESTORE_VARS_BLACKLIST = ['dont', 'load', 'this']
ckpt_vars = tf.train.list_variables(RESTORE_VARS_CKPT)
ass_ops = []
for dst_var in tf.get_collection(tf.GraphKeys.GLOBAL_VARIABLES):
    for (ckpt_var, ckpt_shape) in ckpt_vars:
        if dst_var.name.split(":")[0] == ckpt_var and dst_var.shape == ckpt_shape and ckpt_var not in RESTORE_VARS_BLACKLIST:
            value = tf.train.load_variable(RESTORE_VARS_CKPT, ckpt_var)
            ass_ops.append(tf.assign(dst_var, value))
# Run assign in a session
sess.run(ass_ops)

At the end, just save your new model.

Post a Comment for "How To Restore Tensorflow V1.1.0 Saved Model In V1.13.1"