- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个使用 tf.keras.models.load_model
加载的 keras.models.Model
。
现在有两个选项可以使用这个模型。我可以调用 model.predict(x)
或调用 model(x).numpy()
。这两个选项都给我相同的结果,但 model.predict(x)
的运行时间要长 10 倍以上。
source code中的评论状态:
Computation is done in batches. This method is designed for performance in large scale inputs. For small amount of inputs that fit in one batch, directly using
__call__
is recommended for faster execution, e.g.,model(x)
, ormodel(x, training=False)
我已经用包含 1 的 x
进行了测试; 1,000,000;和 10,000,000 行,model(x)
仍然表现更好。
输入需要多大才能被归类为大规模输入,并且 model.predict(x)
才能表现得更好?
最佳答案
现有的堆栈溢出答案可能对您有用:https://stackoverflow.com/a/58385156/5666087 .我在 tensorflow/tensorflow#33340 上找到了它.该答案建议将 experimental_run_tf_function=False
传递到 model.compile
调用中以恢复到模型执行的 TF 1.x 版本。您也可以完全省略 model.compile
调用(对于预测而言它不是必需的)。
How large does the input need to be to be classified as a large scale input, and for the
model.predict(x)
to perform better?
这是您可以测试的内容。正如文档所述,如果您的数据适合一个批处理,model(x)
可能会比 model.predict(x)
更快。 model.predict(x)
优于 model(x)
的一件事是能够预测多个批处理。如果您想使用 model(x)
对多个批处理进行预测,则必须自己编写循环。 model.predict
还提供其他功能,例如回调。
仅供引用,源代码中的文档已添加到提交 42f469be0f3e8c36624f0b01c571e7ed15f75faf 中, 由于 tensorflow/tensorflow#33340 .
model.predict(x)
的主要行为已实现 here .它不仅仅包含模型的前向传递。这可能是一些速度差异的原因。
I've tested with x containing 1; 1,000,000; and 10,000,000 rows and model(x) still performs better.
这 10,000,000 行是否适合一批......?
关于tensorflow - 何时在 tensorflow 中使用 model.predict(x) 与 model(x),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60159714/
这里有没有人在使用Google Prediction API?为了什么?它“起作用”了吗? 最佳答案 如果您正在寻找实际案例,请查看此案例automatically assigns priority
无论如何,学习R ..: 在简单的x和y回归中,我输入: predict(data1.lm, interval="prediction") 和 predict(data1.lm, interval="
我创建并调整了多个模型,但在尝试预测它们时遇到了问题。我首先按如下方式运行代码来调整 LDA 模型。 library(MASS) library(caret) library(randomForest
问题 我在 R 中训练了一个线性回归来预测 this.target来自 city , 数据框中的变量 data .这个训练是在数据的一个子集上完成的,它由 train.index 指定。 . mode
我正在检查 tf-serving 示例,发现 inception_client.py mnist_client.py 时使用 result = Stub.Predict(request, 10.0)使
我已在 Google ML Engine 中上传了该模型的一个版本,其中包含 saved_model.pb 和一个变量文件夹。当我尝试执行命令时: gcloud ml-engine local pre
请先在我们的 GitHub 存储库中搜索类似问题。如果您找不到类似的示例,您可以使用以下模板: 系统(请填写以下信息): - 操作系统:Ubuntu 18.04 - Python版本:3.6.7 -
我正在研究一个简单的 LL(1) 解析器生成器,我遇到了给定某些输入语法的 PREDICT/PREDICT 冲突问题。例如,给定如下输入语法: E → E + E | P P → 1 我可以
我正在对具有多个预测变量的线性模型的预测值求和,如下例所示,并希望计算该总和的组合方差、标准误差和可能的置信区间。 lm.tree <- lm(Volume ~ poly(Girth,2), data
我是 R 和统计学的新手。所以这个问题可能有点愚蠢,但我想知道 R 中的 predict() 和 predict.lm() 之间是否有任何区别?我认为它们是相同的,但如果它们是相同的,为什么会有两个不
我尝试了针对this question而发布的答案,但是错误没有改变。我试图以相同的方式预处理训练集和测试集。它们来自两个不同的文件,我不确定我的老师是否会把我混合在一起,所以在拆分它们之前进行预处理
使用随机森林包:- #install.packages("randomForest") library(randomForest) 我使用在线代码在我的系统上运行随机森林。我得到了一个具有混淆矩阵和准
我有一个模型 (fit),基于上个月之前的历史信息。现在我想使用我的模型来预测当月的情况。当我尝试调用以下代码时: predicted fit$modelInfo$label [1]“随机森林” 因此
我正在尝试找出应用于列表的操作。我有列表/数组名称预测并执行以下指令集。 predictions[predictions >> a = np.array([1,2,3,4,5]) #define ar
此 R 代码引发警告 # Fit regression model to each cluster y fit$rank 检查 另一种方法是拥有比可用变量更多的参数: fit2 <- lm(y ~
我不是 R 专家。我正在尝试计算多项式模型生成的偏差: f calc.bias(f, polydeg, x))。我使用的整个代码: library(PolynomF) f <- function(x)
谁能帮我解决我的问题?我似乎无法从互联网上得到任何答案。我一直在寻找一整天。所以这是我的问题。我正在使用 opencv4android 2.4.10 和 Android Studio 作为我的 IDE
我可以使用哪种方法来根据姓氏来预测某人的国籍? 我有大量的文字和作者姓氏。我想确定哪些语言是由拉丁语使用者撰写的,哪些文本是由以英语为母语的使用者撰写的,以便研究一组中的某些写作风格模式是否与另一组中
我很好奇克服“冷启动”问题的方法/途径是什么,当新用户或项目进入系统时,由于缺乏有关该新实体的信息,因此进行推荐是一个问题。 我可以考虑做一些基于预测的推荐(例如性别、国籍等)。 最佳答案 您可以冷启
我正在使用零膨胀负二项式模型(包:pscl)对电影通过联系网络(基于电话数据)的传播进行建模 m1 我的变量是: 因变量: 扩散链的长度(计数 [0,36]) 自变量: 电影特征(虚拟变量和连续变量
我是一名优秀的程序员,十分优秀!