In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the knowledge of "how to use Scope in Tensorflow". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
There are two different context managers in Tensorflow to manage tensor and variable names. The first is tf.name_scope and the second is tf.get_variable. Let me explain it in detail with some examples.
1. Use tf.name_scope
Variables and tensors in Tensorflow have named attributes and are used to identify them in symbolic diagrams. If we do not specify a name attribute when we create a variable or tensor, Tensorflow automatically assigns a name.
We can override the default name by specifying an explicit name.
Note: there are two ways to define a new variable in Tensorflow: create a tf.Variable object or call tf.get_variable. Calling tf.get_variable with a new name creates a new variable, but if there is a variable with the same name, this throws a ValueError exception, which tells us that a variable with the same name is not allowed to be redeclared.
From the above code, we can see that tf.name_scope affects variable names created by tf.Variable, but does not affect variable names created by tf.get_variable.
2. Use tf.variable_scope
Unlike tf.name_scope,tf.variable_scope, the name of the variable created by tf.get_variable is modified.
But sometimes we really want to reuse a previously declared variable, what should we do? Tf.variable_scope provides the ability to do this by setting the reuse flag bit to True.
This is the end of the introduction to "how to use Scope in Tensorflow". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.