How to restore variables using CheckpointReader in Tensorflow

后端 未结 3 869
谎友^
谎友^ 2020-12-06 08:42

I\'m trying to restore some variables from checkpoint file if same variable name is in current model.
And I found that there is some way as in Tensorfow Github

S

3条回答
  •  旧巷少年郎
    2020-12-06 09:08

    tf.train.NewCheckpointReader is a nifty method that creates a CheckpointReader object. CheckpointReader has several very useful methods. The method that would be the most relevant to your question would be get_variable_to_shape_map().

    • get_variable_to_shape_map() provides a dictionary with variable names and shapes:

    saved_shapes = reader.get_variable_to_shape_map()
    print 'fire9/squeeze1x1/kernels:', saved_shapes['fire9/squeeze1x1/kernels']

    Please take a look at this quick tutorial below: Loading Variables from Existing Checkpoints

提交回复
热议问题