In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail how to use Summary in Tensorflow, the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have some understanding of the relevant knowledge after reading this article.
1 、 tf.summary.scalar
Used to display scalar information in the following format:
Tf.summary.scalar (tags, values, collections=None, name=None)
For example: tf.summary.scalar ('mean', mean)
This function is usually used when drawing loss,accuary.
2 、 tf.summary.histogram
Used to display histogram information in the following format:
Tf.summary.histogram (tags, values, collections=None, name=None)
For example: tf.summary.histogram ('histogram', var)
It is generally used to show the distribution of variables in the training process.
3 、 tf.summary.distribution
Distribution map, which is generally used to show the weights distribution
4 、 tf.summary.text
You can convert text-type data to tensor and write it to summary:
For example:
Text = "" / a/b/c\\ _ tf.summary.image f\\ _ g\\ _ h\ 2017 "" summary_op0 = tf.summary.text ('text', tf.convert_to_tensor (text)) 5, tf.summary.image
Output probuf with image, and the form of the image that summarizes the data is as follows: 'tag / image/0',' tag / image/1'..., such as: input/image/0, etc.
Format: tf.summary.image (tag, tensor, max_images=3, collections=None, name=Non)
6 、 tf.summary.audio
Show the audio recorded during the training
7 、 tf.summary.merge_all
Merge_all can save all summary to disk for tensorboard display. If there are no special requirements, this sentence can be used to display all kinds of information during training.
Format: tf.summaries.merge_all (key='summaries')
8 、 tf.summary.FileWriter
Specify a file to save the drawing.
Format: tf.summary.FileWritter (path,sess.graph)
You can call its add_summary () method to save the training process data in a file specified by filewriter
Example of Tensorflow Summary usage:
Tf.summary.scalar ('accuracy',acc) # generate accuracy scalar graph merge_summary = tf.summary.merge_all () train_writer = tf.summary.FileWriter (dir,sess.graph) # defines a target file to be written to summary, and dir is the write file address. (definition of cross entropy, optimizer, etc.) for step in xrange (training_step): # training cycle train_summary = sess.run (merge_summary,feed_dict = {...}) # call sess.run operation diagram to generate one-step training process data train_writer.add_summary (train_summary,step) # call the add_summary method of train_writer to save the training process and the number of training steps
Tensorborad is now enabled:
Tensorboard-logdir=/summary_dir
You can see the accuracy curve.
In addition, if I don't want to save all the defined summary information, I can also use the tf.summary.merge method to save the information selectively:
9 、 tf.summary.merge
Format: tf.summary.merge (inputs, collections=None, name=None)
Generally, the tf.get_collection () function is also used to select the information to be saved.
Example:
Tf.summary.scalar ('accuracy',acc) # generates the accuracy scalar graph merge_summary = tf.summary.merge ([tf.get_collection (tf.GraphKeys.SUMMARIES,'accuracy'),... (other information to be displayed)]) train_writer = tf.summary.FileWriter (dir,sess.graph) # defines a target file to write to summary, and dir is the address of the write file. (definition of cross entropy, optimizer, etc.) for step in xrange (training_step): # training cycle train_summary = sess.run (merge_summary,feed_dict = {...}) # call sess.run operation diagram to generate one-step training process data train_writer.add_summary (train_summary,step) # call the add_summary method of train_writer to save the training process and the number of training steps
Use the tf.get_collection function to filter the accuracy information in the summary information in the diagram, where the
Tf.GraphKeys.SUMMARIES is the symbol of summary in collection.
Of course, you can also directly:
Acc_summary = tf.summary.scalar ('accuracy',acc) # generate accuracy scalar graph merge_summary = tf.summary.merge ([acc_summary,... (other information to be displayed)] # the [] here is not enough about how to use Summary in Tensorflow. I hope the above content can be helpful to you and learn more. If you think the article is good, you can share it for more people to see.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.