草庐IT

default-compile

全部标签

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:re.compile 和 re.sub

问题第1部分我得到了这个文件f1:GeorgeWashingtonJoeTaylor我想重新编译它,它看起来像这样f1:(带空格)GeorgeWashingtonJoeTaylor我试过这段代码,但它有点删除了所有内容:importrefile=open('f1.txt')fixed=open('fnew.txt','w')text=file.read()match=re.compile('')forunwantedintext:fixed_doc=match.sub(r'',text)fixed.write(fixed_doc)我的猜测是re.compile行,但我不太确定如何处理它

python - 无法安装 python 模块 : PyCharm Error: "byte-compiling is disabled, skipping"

我刚刚第一次安装PyCharm5并尝试让它正常工作。我有一个简单的python脚本,它试图导入pandas(将pandas导入为pd)。它失败了,因为没有安装pandas...所以我去安装它然后得到一个错误(复制在下面)。我尝试在“首选项”或“帮助”中寻找一些“字节编译”设置,但无济于事。我已经尝试过此处建议的解决方法,包括将默认项目编辑器更改为Python2.7,但这没有帮助(https://github.com/spacy-io/spaCy/issues/114)。我该怎么办?=================Errorbelow=================Executedc

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 - 使用 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 - 运行时错误 : module compiled against API version 0xc but this version of numpy is 0xb

我正在尝试学习机器学习,但无法解决以下错误。[我的环境]MacHighSierra10.13.2Python3.4.5Numpy1.13.3[命令]$python3-c"importjupyter,matplotlib,numpy,pandas,scipy,sklearn"[错误]RuntimeError:modulecompiledagainstAPIversion0xcbutthisversionofnumpyis0xbTraceback(mostrecentcalllast):File"/Users/uekyo/ml/env/lib/python3.4/site-packages

python - 错误: `Loaded runtime CuDNN library: 5005 but source was compiled with 5103` mean?是什么意思

我试图将TensorFlow与GPU结合使用,但出现以下错误:Itensorflow/core/common_runtime/gpu/gpu_device.cc:838]CreatingTensorFlowdevice(/gpu:0)->(device:0,name:TeslaK20m,pcibusid:0000:02:00.0)Etensorflow/stream_executor/cuda/cuda_dnn.cc:347]LoadedruntimeCuDNNlibrary:5005(compatibilityversion5000)butsourcewascompiledwith5