Tensorflow ValueError: No variables to save from

前端 未结 3 1622
天命终不由人
天命终不由人 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条回答
  •  梦毁少年i
    2020-12-23 23:28

    Note that since TF 0.11 — a long time ago yet after the currently accepted answer — tf.train.Saver gained a defer_build argument in its constructor that allows you to define variables after it has been constructed. However you now need to call its build member function when all variables have been added, typically just before finilizeing your graph.

    saver = tf.train.Saver(defer_build=True)
    # build you graph here
    saver.build()
    graph.finalize()
    # now entering training loop
    

提交回复
热议问题