In addition to Weibo, there is also WeChat
Please pay attention

WeChat public account
Shulou
2025-11-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "how to save and restore variables in TensorFLow with Saver". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "TensorFLow how to save and restore variables with Saver"!
Create the file tensor_save.py, save the tensor of the variable v1Magee v2 to checkpoint files, and set the name to v3Percience v4, respectively.
Import tensorflow as tf# Create some variables.v1 = tf.Variable (3, name= "v1") v2 = tf.Variable (4, name= "v2") # Create modely=tf.add (v1 Magneto v2) # Add an op to initialize the variables.init_op = tf.initialize_all_variables () # Add ops to save and restore all the variables.saver = tf.train.Saver ({'v3 blemade v1) v4 parallel V2}) # Later, launch the model, initialize the variables, do some work Save the# variables to disk.with tf.Session () as sess: sess.run (init_op) print ("v1 =", v1.eval ()) print ("v2 =", v2.eval ()) # Save the variables to disk. Save_path = saver.save (sess, "f:/tmp/model.ckpt") print ("Model saved in file:", save_path)
Set up the file tensor_restror.py, and restore the tensor named v3menv4 in checkpoint files to the variable v3menv4 respectively.
Import tensorflow as tf# Create some variables.v3 = tf.Variable (0, name= "v3") v4 = tf.Variable (0, name= "v4") # Create modely=tf.mul (v3 Maher v4) # Add ops to save and restore all the variables.saver = tf.train.Saver () # Later, launch the model, use the saver to restore variables from disk, and# do some work with the model.with tf.Session () as sess: # Restore variables from disk. Saver.restore (sess, f:/tmp/model.ckpt) print ("Model restored.") Print ("v3 =", v3.eval ()) print ("v4 =", v4.eval ()) print ("y =", sess.run (y)) so far, I believe you have a better understanding of "how TensorFLow saves and recovers variables with Saver". You might as well do it in practice! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope





About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.