Tensorflow的tensorflow variable_scope values参数含义 [英] Tensorflow's tensorflow variable_scope values parameter meaning

查看:109
本文介绍了Tensorflow的tensorflow variable_scope values参数含义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在阅读基于Tensorflow的苗条库的源代码,并且它们对 variable_scope values 参数>方法很多,例如此处



从API页面中,我可以看到:


此上下文管理器验证(可选)值是否来自同一图,确保该图为默认图,并推送名称范围和变量范围。


我的问题是:是否只检查来自的变量?

解决方案

variable_scope参数有助于确保变量的唯一性和重用是的,如果您创建两个或更多不同的计算图,则它们不一定共享相同的变量范围;但是,有一些方法可以使它们在图形之间共享,因此可以使用该选项。



可变范围的主要用例是RNN,其中许多权重是相关的并重复使用。这就是有人需要它的原因之一。这样做的另一个主要原因是要确保您在明确表示目的而不是偶然的情况下重用相同的变量。 (对于分布式设置,这可能会成为一个问题。)


I am currently reading a source code for slim library that is based on Tensorflow and they use values argument for variable_scope method alot, like here.

From the API page I can see:

This context manager validates that the (optional) values are from the same graph, ensures that graph is the default graph, and pushes a name scope and a variable scope.

My question is: variables from values are only being checked if they are from the same graph? What are the use cases for this and why someone will need that?

解决方案

The variable_scope parameter helps ensure uniqueness of variables and reuse of variables where desired.

Yes if you create two or more different computation graphs then they wouldn't necessarily share the same variable scope; however, there are ways to get them to be shared across graphs so the option is there.

Primary use cases for variable scope are for RNN's where many of the weights are tied and reused. That's one reason someone would need it. The other main reason it's there is to ensure that you are reusing the same variables when you explicitly mean to and not by accident. (For distributed settings this can become a concern.)

这篇关于Tensorflow的tensorflow variable_scope values参数含义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆