prediction

tensorflow serving prediction as b64 output top result

这一生的挚爱 提交于 2019-12-01 14:05:12
I have a Keras model I converting to a tensorflow serving model. I can successfully convert my pretrained keras model to take b64 input, preprocess that input, and feed it to my model. My problem is that I don't know how to take the prediction data I am getting (which is enormous) and only export the top result. I am doing image segmentation so my output prediction is of shape (?, 473, 473, 3) and I'd like to get the top result and return it in b64 encoded format. What I have currently that just returns the entire prediction: sess = K.get_session() g = sess.graph g_def = graph_util.convert

tensorflow serving prediction as b64 output top result

这一生的挚爱 提交于 2019-12-01 12:34:54
问题 I have a Keras model I converting to a tensorflow serving model. I can successfully convert my pretrained keras model to take b64 input, preprocess that input, and feed it to my model. My problem is that I don't know how to take the prediction data I am getting (which is enormous) and only export the top result. I am doing image segmentation so my output prediction is of shape (?, 473, 473, 3) and I'd like to get the top result and return it in b64 encoded format. What I have currently that

Tensorflow Slim restore model and predict

≡放荡痞女 提交于 2019-12-01 07:29:53
问题 I'm currently trying to learn how to use TF-Slim and I'm following this tutorial: https://github.com/mnuke/tf-slim-mnist. Assuming that I already have a trained model saved in a checkpoint, how do I now use that model and apply it? Like, in the tutorial how do I use my trained MNIST model and feed in a new set of MNIST images, and print the predictions? 回答1: You can try a workflow like: #obtain the checkpoint file checkpoint_file= tf.train.latest_checkpoint("./log") #Construct a model as such

How to create a graph showing the predictive model, data and residuals in R

蓝咒 提交于 2019-12-01 04:04:20
Given two variables, x and y , I run a dynlm regression on the variables and would like to plot the fitted model against one of the variables and the residual on the bottom showing how the actual data line differs from the predicting line. I've seen it done before and I've done it before, but for the life of me I can't remember how to do it or find anything that explains it. This gets me into the ballpark where I have a model and two variables, but I can't get the type of graph I want. library(dynlm) x <- rnorm(100) y <- rnorm(100) model <- dynlm(x ~ y) plot(x, type="l", col="red") lines(y,

GBM multinomial distribution, how to use predict() to get predicted class?

拟墨画扇 提交于 2019-12-01 03:46:22
I am using the multinomial distribution from the gbm package in R. When I use the predict function, I get a series of values: 5.086328 -4.738346 -8.492738 -5.980720 -4.351102 -4.738044 -3.220387 -4.732654 but I want to get the probability of each class occurring. How do I recover the probabilities? Thank You. Take a look at ?predict.gbm , you'll see that there is a "type" parameter to the function. Try out predict(<gbm object>, <new data>, type="response") . smci predict.gbm(..., type='response') is not implemented for multinomial, or indeed any distribution other than bernoulli or poisson. So

How to use save model for prediction in python

◇◆丶佛笑我妖孽 提交于 2019-12-01 00:48:05
I am doing a text classification in python and I want to use it in production environment for making prediction on new document. I am using TfidfVectorizer to build bagofWord. I am doing: X_train = vectorizer.fit_transform(clean_documents_for_train, classLabel).toarray() Then I am doing cross validation and building the model using SVM. After that I am saving the model. For making prediction on my test data I am loading that model in another script where I have the same TfidfVectorizer and I know I can't do fit_transform on my testing data. I have to do: X_test = vectorizer.transform(clean

How to predict survival probabilities in R?

房东的猫 提交于 2019-11-30 22:36:28
I have data called veteran stored in R. I created a survival model and now wish to predict survival probability predictions. For example, what is the probability that a patient with 80 karno value, 10 diagtime , age 65 and prior=10 and trt = 2 lives longer than 100 days? In this case the design matrix is x = (1,0,1,0,80,10,65,10,2) Here is my code: library(survival) attach(veteran) weibull <- survreg(Surv(time,status)~celltype + karno+diagtime+age+prior+trt ,dist="w") and here is the output: Any idea how to predict the survival probabilities? You can get predict.survreg to produce predicted

Appending predicted values and residuals to pandas dataframe

六月ゝ 毕业季﹏ 提交于 2019-11-30 22:18:33
It's a useful and common practice to append predicted values and residuals from running a regression onto a dataframe as distinct columns. I'm new to pandas, and I'm having trouble performing this very simple operation. I know I'm missing something obvious. There was a very similar question asked about a year-and-a-half ago, but it wasn't really answered. The dataframe currently looks something like this: y x1 x2 880.37 3.17 23 716.20 4.76 26 974.79 4.17 73 322.80 8.70 72 1054.25 11.45 16 And all I'm wanting is to return a dataframe that has the predicted value and residual from y = x1 + x2

用spark ml pipeline尝试kaggle比赛

牧云@^-^@ 提交于 2019-11-30 18:06:36
一、关于spark ml pipeline与机器学习 一个典型的机器学习构建包含若干个过程 1、源数据ETL 2、数据预处理 3、特征选取 4、模型训练与验证 以上四个步骤可以抽象为一个包括多个步骤的流水线式工作,从数据收集开始至输出我们需要的最终结果。因此,对以上多个步骤、进行抽象建模,简化为流水线式工作流程则存在着可行性,对利用spark进行机器学习的用户来说,流水线式机器学习比单个步骤独立建模更加高效、易用。 受 scikit-learn 项目的启发,并且总结了MLlib在处理复杂机器学习问题的弊端(主要为工作繁杂,流程不清晰),旨在向用户提供基于DataFrame 之上的更加高层次的 API 库,以更加方便的构建复杂的机器学习工作流式应用。一个pipeline 在结构上会包含一个或多个Stage,每一个 Stage 都会完成一个任务,如数据集处理转化,模型训练,参数设置或数据预测等,这样的Stage 在 ML 里按照处理问题类型的不同都有相应的定义和实现。两个主要的stage为Transformer和Estimator。Transformer主要是用来操作一个DataFrame 数据并生成另外一个DataFrame 数据,比如svm模型、一个特征提取工具,都可以抽象为一个Transformer。Estimator 则主要是用来做模型拟合用的

10.优化器

╄→гoц情女王★ 提交于 2019-11-30 17:01:27
import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data #载入数据集 mnist = input_data.read_data_sets("MNIST_data",one_hot=True) #每个批次的大小 batch_size = 64 #计算一共有多少个批次 n_batch = mnist.train.num_examples // batch_size #定义两个placeholder x = tf.placeholder(tf.float32,[None,784]) y = tf.placeholder(tf.float32,[None,10]) #创建一个简单的神经网络 W = tf.Variable(tf.zeros([784,10])) b = tf.Variable(tf.zeros([10])) prediction = tf.nn.softmax(tf.matmul(x,W)+b) #交叉熵代价函数 # loss = tf.losses.softmax_cross_entropy(y,prediction) loss = tf.losses.mean_squared_error(y,prediction) #使用梯度下降法 # train_step =