我想预测lstm 7次。我必须从model.predict()获得输出,并使用输出再次预测到7倍。 这是代码。 data = 0
y_pred=0
data[0] = model.predict(X_test_t)
for i in range(7):
data[i+1] = model.predict(data[i])
print(data) 当我运行它时,显示如下错误 File "test_load_model.py", line 60, in <module>
data[0] = model.predict(X_test_t)
我刚接触Keras和python,现在我正在使用Keras来寻找数据模型并使用该model.predict进行优化,但是model.predict只能将输入作为至少包含2个元素的numpy数组。
我的代码是
import keras
from keras.models import Sequential
from keras.layers import Dense
from keras.optimizers import SGD
import numpy as np
x = np.arange(-2,3.0,0.01)
y = x**2 - 2*x + 1
model = Sequenti
嗨,我有一个数据的测试,我试图预测使用一个高斯HMM与HMM学习。
当我这么做时:
y = model.predict(test)
y
我让hmm能够很好地产生和排列状态。
然而,如果我这样做:
for i in range(0,len(test)):
y = model.predict(test[:i])
我只知道你被设定为1。
有人能帮忙吗?
更新
下面是进行迭代的代码
培训组为0-249:
for i in range(251,len(X)):
test = X[:i]
y = model.predict(test)
print(y[len(y)-1])
我已经用谷歌搜索了我能想到的问题的每一个版本,但在我的生活中,我找不到一个基本的tensorflow.js训练tf.browser.fromPixels(图像)来得到是或否的例子。我能找到的所有例子都是从预先训练好的网络开始的。 我已经建立了一个25x25像素图像的数据库,并将它们都存储为一个变量中的画布,如下所示: let data = {
t: [canvas1, canvas2, canvas3, ... canvas3000 ....],
f: [canvas1, canvas2, ... and so on ...]
} 我认为这样做应该是微不足道的: data.t
我有以下问题。我正在使用Tensorflow Keras模型来评估连续的传感器数据。我的模型输入由15个传感器数据帧组成。因为函数model.predict()花费了将近1秒的时间,所以我想异步执行这个函数,这样我就可以收集这段时间内的下一个数据帧。为此,我创建了一个具有多处理库和用于model.predict的函数的池。我的代码看起来像这样:
def predictData(data):
return model.predict(data)
global model
model = tf.keras.models.load_model("Network.h5")
m
在我的神经网络中,我试图在预测阶段保持辍学率。我试图通过在tensorflow 2.0RC中使用tensorflow.keras.backend.set_learning_phase(1)来实现这一点。
当我调用model.compile时,问题就出现了,它似乎在预测阶段关闭了辍学。
下面的代码演示如何设置学习阶段。在模型编制之前,预测是半随机的,和预期的一样。模型编译后,预测不再是半随机的,尽管学习阶段仍然是1。
import tensorflow as tf
from tensorflow import keras
import tensorflow.keras.backend as K
我只想用自动回归算法来建立老派的模型。我发现在statsmodel包中有一个它的实现。我已经阅读了这些文档,据我所知,它应该像ARIMA一样工作。这是我的密码:
import statsmodels.api as sm
model = sm.tsa.AutoReg(df_train.beer, 12).fit()
当我想预测新的值时,我试着遵循文档:
y_pred = model.predict(start=df_test.index.min(), end=df_test.index.max())
# or
y_pred = model.predict(start=100, end=1000)
我刚刚成功地完成了一个tf.keras顺序模型的训练,并编写了一个单独的"Flask“脚本,将保存的模型加载到我上传到Heroku的应用程序中。一切都成功了。但是,当我在玩的时候,我意识到对于我的需求,我只需要导入Flask,从flask以及pandas,numpy和tensorflow.python.keras.models导入load_model的请求: from tensorflow.python.keras.models import load_model
from flask import Flask, request
import pandas as pd
import
#train model
#here is one sample
sample = validation_X[0].reshape(1, -1)
#print the sample for reference
print(sample)
#show the weights for reference
print(model.get_weights())
#show prediction
print(model.predict(sample))
#another prediction that is the same as above
print(model.predict(samp
在tensorflow会话中执行keras的模型预测时,我目前遇到了一个问题。
with tf.Session(graph=graph) as sess:
sess.run(tf.global_variables_initializer())
## want to know how to add model.predict() inside this condition
predictions = model.predict(#my_model)
#predictions output is same not appending
或者任何替代方法都会很有帮助。
我的代码
const model = tf.loadLayersModel('../model/model.json');
// python
function pyFun(arrayOne){
var arrayReturn = new Array(5000);
for (i=0;i<5000;i++){
arrayReturn[i]=0;
}
var arrayTwo = arrayOne.map(myFunction);
function myFuncti
我试着在tf中建立一个神经网络,作为初学者的挑战,而且我的模型不是很好,很多时候它不会很精确(虽然有时精度是1,但大多数时候不是,即使这样损失也很高。)
所以我有两个问题:
我如何改进这个神经网络?
使用Input作为输入层和使用Dense有什么区别?
以下是代码:
import tensorflow as tf
from tensorflow import keras
model = keras.Sequential()
model.add(tf.keras.Input(shape=(2,)))
#model.add(keras.layers.Dense(2))
model
我试图找到一个预测的Y值(输出是数字的)与x输入使用字符串(例如。业务类型、部门和地区)。使用后:
print(model.predict([['Finance and Control'], ['EMEA'], ['Professional Services']]))
它返回了以下错误:AttributeError: 'numpy.ndarray' object has no attribute 'predict'
import pickle
model = pickle.load(open('model3
我想评估一个模型,同时也捕捉到倒数第二层的激活。我用作为解决方案。我使用pen_ulti_activs = layer_outs[-2]访问倒数第二个激活。
但是,为了再次检查该解决方案是否真正有效,我在代码中添加了一个断言,通过比较从functor返回的最后一层激活和从model.predict返回的数组来验证来自functor的激活是否与model.predict的激活相匹配。但是断言失败了。因此,我想我误解了这个相互关联的答案是如何使用的。
from keras import backend as K
def evaluate_model(model, test_gen):
在python中,您可以简单地向predict()传递一个numpy数组,以便从您的模型中获得预测。使用Java与SavedModelBundle的等价性是什么
Python
model = tf.keras.models.Sequential([
# layers go here
])
model.compile(...)
model.fit(x_train, y_train)
predictions = model.predict(x_test_maxabs) # <= This line
Java
SavedModelBundle model = SavedModelBun
我想计算8种不同型号的“负”标签的f1评分。我的前3个模型的代码和结果的数据文件如下所示。如何创建一个不需要为每个模型编写单独代码的函数?
# Train model with vectorizer and classifier
# Model training
from sklearn.model_selection import train_test_split
Independent_var = reviews_english['tokenized']
Dependent_var = reviews_english['sentiment']
IV_tr
这个代码很好用!
val model = new LogisticRegressionWithLBFGS().setNumClasses(2).run(training)
我可以打电话给model.predict(.)
但是,当我试图设置模型参数时,我不能调用model.predict (例如,用下面的代码),我无法调用对模型变量的预测。
val model = new LogisticRegressionWithLBFGS().setNumClasses(2)
model.optimizer.setUpdater(new L1Updater).setRegParam(0.0000001).
我是Kotlin的新手,尝试将一个项目从Java转换为Kotlin
我只需要最后一步,我不明白发生了什么:
我接到了Not enough information to infer type variable T on model.predict的电话
override fun link(word: String): LinkSuggestion {
val input: DoubleArray = gramToInt.toArray(word)
val output: Array<Any> = model.predict(input)