Tensorflow ValueError: No variables to save from

前端 未结 3 1623
天命终不由人
天命终不由人 2020-12-23 23:05

I have written a tensorflow CNN and it is already trained. I wish to restore it to run it on a few samples but unfortunately its spitting out:

ValueEr

3条回答
  •  借酒劲吻你
    2020-12-23 23:29

    Simply, there should be at least one tf.variable that is defined before you create your saver object.

    You can get the above code running by adding the following line of code before the saver object definition.

    The code that you need to add has come between the two ###.

    import tensorflow as tf
    
    import main
    import Process
    import Input
    
    eval_dir = "/Users/Zanhuang/Desktop/NNP/model.ckpt-30"
    checkpoint_dir = "/Users/Zanhuang/Desktop/NNP/checkpoint"
    
    init_op = tf.initialize_all_variables()
    
    ### Here Comes the fake variable that makes defining a saver object possible.
    _ = tf.Variable(initial_value='fake_variable')
    
    ###
    saver = tf.train.Saver()
    ...
    

提交回复
热议问题