- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
state = cell.zero_state(batchsize, tf.float32).eval()
我正在尝试关注这个 https://github.com/kvfrans/twitch/blob/master/sample.py#L45解码和运行经过训练的 tensorflow 模型的示例,但似乎使用的 tensorflow 代码是旧版本。我已经设法修复了对 v 1.0.0 的大多数调用,但我被困在上面的代码行给我以下错误的地方:
Traceback (most recent call last):
File "server.py", line 1, in <module>
from sample import *
File "/home/user/twitch/sample.py", line 75, in <module>
print predict("this game is")
File "/home/user/twitch/sample.py", line 46, in predict
state = initialstate.eval()
AttributeError: 'tuple' object has no attribute 'eval'
关于如何修复 .eval()
和 state
有什么想法吗?它稍后用于:
guessed_logits, state = sess.run([logits, final_state], feed_dict={input_data: primer, initialstate: state})
最佳答案
.eval()
method 仅在 tf.Tensor
上实现,但正如其他人所观察到的,cell.zero_state()
方法返回一个 tuple
对象。
tf.Session.run()
方法了解如何解包元组,而 tf.Tensor.eval()
只是一个方便的包装器,用于调用 tf.Session.run()
"default" session 中的单个张量。使用此观察,您可以切换此行:
state = cell.zero_state(batchsize, tf.float32).eval()
...具有以下内容:
state = tf.get_default_session().run(cell.zero_state(batchsize, tf.float32))
关于python - Tensorflow:AttributeError: 'tuple' 对象没有属性 'eval',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42677650/
在我看来 eval()受到与 goto 相同的蔑视。由 eval ,我的意思是将字符串作为代码执行的函数,如在 PHP、Python、JavaScript 等中看到的。是否有使用 eval() 的情况
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 9 年前。 Improve this ques
我有几十个条件(例如,foo > bar)需要在 DataFrame 的 ~1 MM 行上进行评估,最简洁的方法编写此代码是为了将这些条件存储为字符串列表,并创建 bool 结果的 DataFrame
我正在创建一种编译为字节码并在自定义 VM 上运行的小型语言,其架构在很大程度上受到了我所阅读的有关 Python 和 Lua 的影响。有两个堆栈 - 一个存储函数参数、局部变量和临时值的数据堆栈,以
我正在尝试运行此代码: var aaa = await page.$$eval(selector, list => (list, value) => { return reso
我知道标题听起来很复杂,但为了保持动态,这是有目的的;) 示例(请注意,假定这些示例代码位于外部 eval 内) //Ex1 this works eval('function test (){}')
这是交易,我们有一个很大的 JS 库需要压缩,但是 YUI compressor如果发现“eval”语句,它不会完全压缩代码,因为担心它会破坏其他东西。这很好,但是我们确切地知道什么正在被评估,所以我
每门计算机科学类(class)中都讲授过这一点,并且在许多书籍中都写到程序员不应使用 GoTo。甚至还有一个 xkcd关于它的漫画。我的问题是我们是否达到了可以对 Eval 说同样的事情的地步? Go
这两种方法中的一种是否必须被优先使用,还是仅取决于口味? #!/usr/bin/env perl use warnings; use strict; use DBI; my $db = 'sqlite
如果存在“eval()”,uglify 不会破坏变量。命令行: uglifyjs script/script.js --compress --mangle --unsafe/path/to/scrip
我刚刚开始使用 Julia。我正在尝试使用 eval(在 Julia 中)来在函数中定义一组变量。假设我想将 v1 设置为 2: function fun_test(varargs...) v1
这个问题在这里已经有了答案: When is JavaScript's eval() not evil? (27 个答案) 关闭2 年前。 我从未遇到过需要 eval() 的情况。 人们常常说 []
这个问题在这里已经有了答案: "Variable" variables in JavaScript (9 个回答) Use dynamic variable names in JavaScript
好的 - 我有一个非常具体的案例,我需要使用 eval()。在人们告诉我我根本不应该使用 eval() 之前,让我透露一下我知道 eval 的性能问题、安全问题和所有这些问题。我在非常狭窄的情况下使用
我的问题是关于 JavaScript 闭包和 Eval() 函数。 我有一些看起来像这样的代码,还有一些其他 jQuery 插件相关的代码没有显示。如果需要,我可以用更多代码更新问题。 var _Cu
...或者有更好的方法来实现记忆化吗? Function.memoize = function(callableAsString) { var r = false, callable,
当我尝试在jmeter中执行以下代码时: import org.json.JSONArray; import org.json.JSONObject; String jsonString = prev
根据Mozilla docs为了使用 eval 执行函数,它必须被包装在 ( ) 中,即如果您不使用它们,那么它将被视为字符串. eval as a string defining function
标题看起来很蠢,但我不知道如何准确表达,抱歉。 我有一个程序需要评估一些用户代码(通过 RestrictedPython 以确保安全),并且我想将一个函数放入评估的全局变量中,以便它可以在评估时向我打
以下需要在函数范围内,因为在交互式控制台模式下不会发生奇怪的行为。 以下函数按预期返回 5 (function() { var x = 5; return eval("x"); })() 一个简单透明
我是一名优秀的程序员,十分优秀!