草庐IT

default_scope

全部标签

python - 'autodoc_default_flags' 在 python Sphinx 配置中如何工作?

我正在尝试使用Sphinx1.4和sphinx-apidoc以及sphinx.ext.autodoc扩展为我的python类生成文档。我有很多模块,我希望每个模块只显示类名,而不是类中方法的完整列表(我的代码中都有文档字符串)。这是我的conf.py文件的片段:sys.path.insert(0,'/blah/sphinx/src')extensions=['sphinx.ext.autodoc']autodoc_member_order='bysource'autodoc_default_flags=['no-members']这是一个玩具模块(my_module.py),我用它来了

python - Tensorflow: 'tf.get_default_session()` 在 sess=tf.Session() 为 None 之后

我试图找出为什么tf.get_default_session()总是返回None类型:importtensorflowastftf.reset_default_graph()init=tf.global_variables_initializer()sess=tf.Session()sess.run(init)default=tf.get_default_session()default==None#True我不知道为什么default=tf.get_default_session()是None因为我认为它应该返回上一个session。谁能弄清楚我的代码有什么问题?

python - 属性错误 : module 'tensorflow' has no attribute 'reset_default_graph'

我已经安装了tensorflow版本r0.11。在我的文件名cartpole.py中,我导入了tensorflow:importtensorflowastf并使用它:tf.reset_default_graph()尝试在PyCharm中运行我的项目时出现此错误:intf.reset_default_graph()AttributeError:module'tensorflow'hasnoattribute'reset_default_graph'我该如何修复这个错误? 最佳答案 此功能已弃用。请改用tf.compat.v1.rese

python - TensorFlow 2.0 : how to group graph using tf. 喀拉斯? tf.name_scope/tf.variable_scope 不再使用了吗?

回到TensorFlowinception模块,通过使用tf.name_scope或tf将它们分组.variable_scope.利用这些运算符,我们能够方便地构造计算图,从而使TensorBoard的图View更容易解释。只是结构化组的一个例子:这对于调试复杂的架构非常方便。不幸的是,tf.keras似乎忽略了tf.name_scope并且tf.variable_scope在TensorFlow>=2.0中消失了。因此,像这样的解决方案......withtf.variable_scope("foo"):withtf.variable_scope("bar"):v=tf.get_va

python - 为什么 required 和 default 在ndb中是互斥的?

在旧的googleappenginedatastoreAPI中,“required”和“default”可以一起用于属性定义。使用ndb我得到一个ValueError:repeated,requiredanddefaultaremutallyexclusive.示例代码:fromgoogle.appengine.extimportndbfromgoogle.appengine.extimportdbclassNdbCounter(ndb.Model):#raisesValueErrorcount=ndb.IntegerProperty(required=True,default=1)c

python - 是否允许在 Python 中修改 func_defaults(Python 3.x 中的 __defaults__)?

我试过在Python2.6中这样做,它确实“有效”:>>>deff(i='I'):returni...>>>f.func_defaults=(10,)>>>f()10但这是官方指定的行为,还是我遇到了特定于实现的行为? 最佳答案 在thedocumentationfunc_defaults被记录为“可写”,因此它似乎是已定义的行为。 关于python-是否允许在Python中修改func_defaults(Python3.x中的__defaults__)?,我们在StackOverflo

python - 谷歌 API Python unauthorized_client : Unauthorized client or scope in request

尝试运行我的代码时出现此错误:oauth2client.client.AccessTokenRefreshError:unauthorized_client:Unauthorizedclientorscopeinrequest.这是我的代码:importjsonimportrequestsimporthttplib2fromoauth2client.clientimportSignedJwtAssertionCredentialsfromapiclient.discoveryimportbuildif__name__=='__main__':json_key_file='my-key.

python - 使用 Django 的新 i18n_patterns : How to fall back to the default language specified in the settings module?

我正在使用Django1.4的新i18n_patterns:fromdjango.conf.urlsimportpatterns,include,urlfromdjango.conf.urls.i18nimporti18n_patternsfromdjango.contribimportadminadmin.autodiscover()urlpatterns+=i18n_patterns('',url(r'^admin/',include(admin.site.urls)),)它适用于所有活跃的语言:/en/admin/#Ok/es/admin/#Ok但这失败了:/admin/#404

python - 不要使用 tf.reset_default_graph() 清除嵌套图

我有一堆函数,它们创建了计算图的一部分。在一些这样的功能中,我做withtf.name_scope("my_scope_name"):self._eye_n_components=tf.eye(se...在我调用的最顶层函数的开头tf.reset_default_graph()然后调用那些部分函数,​​它们也可以相互调用。不幸的是,我得到一个错误Error:Donotusetf.reset_default_graph()toclearnestedgraphs.Ifyouneedaclearedgraph,exitthenestingandcreateanewgraph.几个问题。1)什

没有参数的 Python 'raise' : what is "the last exception that was active in the current scope"?

Python的文档说:Ifnoexpressionsarepresent,raisere-raisesthelastexceptionthatwasactiveinthecurrentscope.(Python3:https://docs.python.org/3/reference/simple_stmts.html#raise;Python2.7:https://docs.python.org/2.7/reference/simple_stmts.html#raise。)但是,“最后激活”的概念似乎已经改变。见证以下代码示例:#from__future__importprint_f