简体   繁体   中英

How to reset a graph by name in tensorflow?

My understanding about working with multiple tensorflow graphs is that if i am creating a graph with tf.Graph() then there are two graphs that tensorflow has created for me. One is the graph that tensorflow sets as default when i am within no context and one that i created using tf.Graph() that will be default when i am within tf.Graph().as_default(): context. Now, How do i go about resetting the graph i created with tf.Graph() since tf.reset_default_graph() cannot be used inside a tf.Graph().as_default(): context

You can create a new tf.Graph() and replace the previous one. As long as you remember to replace all of the references, the old graph will be garbage collected, so this solution is equivalent to resetting your existing graph.

Just remember about all of the references! You would likely need to recreate the session that used the previous graph, as I don't think that there is a way to just replace the graph reference.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM