All Projects → AshutoshDongare → Tensorflow-Wide-Deep-Local-Prediction

AshutoshDongare / Tensorflow-Wide-Deep-Local-Prediction

Licence: other
This project demonstrates how to run and save predictions locally using exported tensorflow estimator model

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Tensorflow-Wide-Deep-Local-Prediction

Math object detection
An image recognition/object detection model that detects handwritten digits and simple math operators. The output of the predicted objects (numbers & math operators) is then evaluated and solved.
Stars: ✭ 52 (+85.71%)
Mutual labels:  tensorflow-tutorials, tensorflow-experiments, tensorflow-models, tensorflow-examples
Tensorlayer Tricks
How to use TensorLayer
Stars: ✭ 357 (+1175%)
Mutual labels:  tensorboard, tensorflow-tutorials, tensorflow-experiments, tensorflow-models
Letslearnai.github.io
Lets Learn AI
Stars: ✭ 33 (+17.86%)
Mutual labels:  tensorflow-tutorials, tensorflow-models, tensorflow-examples
Tensorflow Sentiment Analysis On Amazon Reviews Data
Implementing different RNN models (LSTM,GRU) & Convolution models (Conv1D, Conv2D) on a subset of Amazon Reviews data with TensorFlow on Python 3. A sentiment analysis project.
Stars: ✭ 34 (+21.43%)
Mutual labels:  tensorflow-tutorials, tensorflow-experiments, tensorflow-examples
Age-Gender Estimation TF-Android
Age + Gender Estimation on Android with TensorFlow Lite
Stars: ✭ 34 (+21.43%)
Mutual labels:  tensorflow-experiments, tensorflow-models, tensorflow-examples
TensorFlow-Multiclass-Image-Classification-using-CNN-s
Balanced Multiclass Image Classification with TensorFlow on Python.
Stars: ✭ 57 (+103.57%)
Mutual labels:  tensorflow-tutorials, tensorflow-experiments, tensorflow-models
Free Tensorflow
Tensorflow 免费中文视频教程,开源代码,免费书籍.
Stars: ✭ 83 (+196.43%)
Mutual labels:  tensorflow-tutorials, tensorflow-models, tensorflow-examples
Android-Machine-Learning-With-TensorFlow
Tensor Flow implementation for Android
Stars: ✭ 17 (-39.29%)
Mutual labels:  tensorflow-experiments, tensorflow-models, tensorflow-examples
Androidtensorflowmachinelearningexample
Android TensorFlow MachineLearning Example (Building TensorFlow for Android)
Stars: ✭ 1,369 (+4789.29%)
Mutual labels:  tensorflow-tutorials, tensorflow-models, tensorflow-examples
Ml Classifier Ui
A UI tool for quickly training image classifiers in the browser
Stars: ✭ 224 (+700%)
Mutual labels:  tensorflow-tutorials, tensorflow-experiments, tensorflow-examples
Awesome-Tensorflow2
基于Tensorflow2开发的优秀扩展包及项目
Stars: ✭ 45 (+60.71%)
Mutual labels:  tensorflow-experiments, tensorflow-models, tensorflow-examples
Ml Classifier
A tool for quickly training image classifiers in the browser
Stars: ✭ 97 (+246.43%)
Mutual labels:  tensorflow-tutorials, tensorflow-experiments, tensorflow-examples
Dog-or-Cat-TensorflowSharp-Example
An example for TensorflowSharp - classify an image as a dog or cat.
Stars: ✭ 15 (-46.43%)
Mutual labels:  tensorflow-tutorials, tensorflow-experiments, tensorflow-examples
Tensorflow template application
TensorFlow template application for deep learning
Stars: ✭ 1,851 (+6510.71%)
Mutual labels:  csv, tensorboard, wide-and-deep
Machine-Learning
🌎 I created this repository for educational purposes. It will host a number of projects as part of the process .
Stars: ✭ 38 (+35.71%)
Mutual labels:  tensorflow-experiments, tensorflow-models
Neural-Turing-Machine
TensorFlow implementation of a Neural Turing Machine
Stars: ✭ 23 (-17.86%)
Mutual labels:  tensorflow-models, tensorflow-examples
Traffic-Light-Classification
A detailed tutorial on how to build a traffic light classifier with TensorFlow for the capstone project of Udacity's Self-Driving Car Engineer Nanodegree Program.
Stars: ✭ 110 (+292.86%)
Mutual labels:  tensorflow-tutorials, tensorflow-models
tensorflow-fifo-queue-example
Example on how to use a Tensorflow Queue to feed data to your models.
Stars: ✭ 39 (+39.29%)
Mutual labels:  tensorflow-tutorials, tensorflow-examples
TensorFlow
Swift high-level API for TensorFlow.
Stars: ✭ 49 (+75%)
Mutual labels:  tensorboard, tensorflow-models
generative-art
🌈🎨 Generative Art is the idea realized as genetic code of artificial events, as construction of dynamic complex systems able to generate endless variations. This is also a nuxt-module (@luxdamore/nuxt-canvas-sketch) - [three.js, tensorflow.js and gsap are not included].
Stars: ✭ 41 (+46.43%)
Mutual labels:  tensorflow-tutorials, tensorflow-examples

Tensorflow Wide & Deep Local Prediction to CSV

Overview

If you do not want to deploy full Tensorflow serving for production but still want to be able to perform local predictions and save the results, this sample will help you achieve that.

This sample builds on top of Tensorflow sample for implementing Wide & Deep estimator Model. Training part of the code has been adopted from Tensorflow samples on Github. This sample exports Tensorflow estimator trained model to a local directory, loads & runs the saved model and saves the results to a CSV file.

Check out more details on Tensorflow Wide and Deep estimator model

Running the code

Setup

Setup the tensorflow wide & Deep as described in the orginal sample given below

The Census Income Data Set that this sample uses for training is hosted by the UC Irvine Machine Learning Repository. We have provided a script that downloads and cleans the necessary files.

python data_download.py

This will download the files to /tmp/census_data. To change the directory, set the --data_dir flag.

Training

You can run the code locally as follows:

python wide_deep.py

The model is saved to /tmp/census_model by default, which can be changed using the --model_dir flag.

To run the wide or deep-only models, set the --model_type flag to wide or deep. Other flags are configurable as well; see wide_deep.py for details.

The final accuracy should be over 83% with any of the three model types.

TensorBoard

Run TensorBoard to inspect the details about the graph and training progression.

tensorboard --logdir=/tmp/census_model

Exporting Trained Model

We will add code to export trained model. Add below code snippet right after the training the model and run the training and export.

  '''Export Trained Model for Serving'''
  wideColumns, DeepColumns = build_model_columns()
  feature_columns = DeepColumns
  feature_spec = tf.feature_column.make_parse_example_spec(feature_columns)
  export_input_fn = tf.estimator.export.build_parsing_serving_input_receiver_fn(feature_spec)
  servable_model_dir = "/tmp/census_exported"
  servable_model_path = model.export_savedmodel(servable_model_dir, export_input_fn)
  print("Done Exporting at Path - %s", servable_model_path )

We are simply reusing build_model_columns() function present in training code to create features and export the model

Once we run the training and export, we should get a confirmation that the model has been exported at a path which looks like /tmp/census_exported/1520271391. The last level would be different for each export so please note it down. we will be using it in the prediction code as mentioned in below section.

Running Predictions and Saving the results

wide_deep_predict.py contains code for loading saved model to run on input data census_input.csv and save the results to output CSV file census_output.csv

Configure exported model path in wide_deep_predict.py as exported_path = '/tmp/census_exported/1520271391'

This code loads the exported model, reads input CSV line by line, prepares model input for prediction, runs prediction and writes results in Output CSV file.

Output file contains all input parameters in addition of results of prediction named as Predicted_income_bracket and probability. Note that the first result column has values 0 or 1. Label value given in the training (Positive Label) will be treated as 1, >50K in this case. If required you can write actual label values to CSV by checking the results.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].