All Projects → TensorLab → Tensorfx

TensorLab / Tensorfx

Licence: apache-2.0
TensorFlow framework for training and serving machine learning models

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Tensorfx

Real Time Ml Project
A curated list of applied machine learning and data science notebooks and libraries across different industries.
Stars: ✭ 143 (-24.34%)
Mutual labels:  ml
Sig Mlops
CDF SIG MLOps
Stars: ✭ 165 (-12.7%)
Mutual labels:  ml
Andrew Ng Notes
This is Andrew NG Coursera Handwritten Notes.
Stars: ✭ 180 (-4.76%)
Mutual labels:  ml
Jetson
Helmut Hoffer von Ankershoffen experimenting with arm64 based NVIDIA Jetson (Nano and AGX Xavier) edge devices running Kubernetes (K8s) for machine learning (ML) including Jupyter Notebooks, TensorFlow Training and TensorFlow Serving using CUDA for smart IoT.
Stars: ✭ 151 (-20.11%)
Mutual labels:  ml
Prophecis
Prophecis is a one-stop cloud native machine learning platform.
Stars: ✭ 156 (-17.46%)
Mutual labels:  ml
Ee Outliers
Open-source framework to detect outliers in Elasticsearch events
Stars: ✭ 172 (-8.99%)
Mutual labels:  ml
Dl
Курс "Глубокое обучение (Deep Learning)" (ВМК, МГУ имени М.В. Ломоносова)
Stars: ✭ 141 (-25.4%)
Mutual labels:  ml
Matrix
Matrix manipulation and computation library
Stars: ✭ 185 (-2.12%)
Mutual labels:  ml
Pzad
Курс "Прикладные задачи анализа данных" (ВМК, МГУ имени М.В. Ломоносова)
Stars: ✭ 160 (-15.34%)
Mutual labels:  ml
Alloy
Make usage of Metal API a pleasure
Stars: ✭ 178 (-5.82%)
Mutual labels:  ml
Audioowl
Fast and simple music and audio analysis using RNN in Python 🕵️‍♀️ 🥁
Stars: ✭ 151 (-20.11%)
Mutual labels:  ml
Datasciencevm
Tools and Docs on the Azure Data Science Virtual Machine (http://aka.ms/dsvm)
Stars: ✭ 153 (-19.05%)
Mutual labels:  ml
Atari
AI research environment for the Atari 2600 games 🤖.
Stars: ✭ 174 (-7.94%)
Mutual labels:  ml
Djl
An Engine-Agnostic Deep Learning Framework in Java
Stars: ✭ 2,262 (+1096.83%)
Mutual labels:  ml
Scio
A Scala API for Apache Beam and Google Cloud Dataflow.
Stars: ✭ 2,247 (+1088.89%)
Mutual labels:  ml
Ml Forex Prediction
Predicting Forex Future Price with Machine Learning
Stars: ✭ 142 (-24.87%)
Mutual labels:  ml
Transmogrifai
TransmogrifAI (pronounced trăns-mŏgˈrə-fī) is an AutoML library for building modular, reusable, strongly typed machine learning workflows on Apache Spark with minimal hand-tuning
Stars: ✭ 2,084 (+1002.65%)
Mutual labels:  ml
Classifai
Enhance your WordPress content with Artificial Intelligence and Machine Learning services.
Stars: ✭ 188 (-0.53%)
Mutual labels:  ml
Irken Compiler
Irken is a statically typed variant of Scheme. Or a lisp-like variant of ML.
Stars: ✭ 184 (-2.65%)
Mutual labels:  ml
Ml
Machine learning tools in JavaScript
Stars: ✭ 2,206 (+1067.2%)
Mutual labels:  ml

Introduction to TensorFX

TensorFX is an end to end application framework to simplifies machine learning with TensorFlow - both training models and using them for prediction. It is designed from the ground up to make the mainline scenarios simple with higher level building blocks, while ensuring custom or complex scenarios remain possible by preserving the flexibility of TensorFlow APIs.

There are some important principles that shape the design of the framework:

  1. Simple, consistent set of usage patterns Local or cloud, single node or distributed execution, in-memory data or big data sharded across files, you should have to write code once, in a single way regardless of how the code executes.

  2. A Toolbox with Useful Abstractions The right entrypoint for the task at hand, starting with off-the-shelf algorithms that let you focus on feature engineering and hyperparam tuning. If you need to solve something unqiue, you can focus on building TensorFlow graphs, rather than infrastructure code (distributed cluster setup, checkpointing, logging, exporting models etc.).

  3. Declarative Using YAML, JSON, and simplified Python interfaces to minimize the amount of boilerplate code.

OK, enough context... here is some information to get you started.

Getting Started

Once you have a Python environment (recommendation: use Miniconda), installation is straightforward:

pip install tensorflow
pip install tensorfx

Note that TensorFX depends on TensorFlow 1.0, and supporting libraries such as numpy and pandas.

Documentation

Documentation is at https://tensorlab.github.io/tensorfx/. This includes API reference topics, as well as conceptual and how-to topics. They are a work-in-progress, but check them out! There are a few samples that demonstrate how to get started as well in the repository. Likewise, more to be added over time.

Contributions and Development

We welcome contributions in form of ideas, issues, samples as well as code. Since the project is at a super-early stage, and evolving rapidly, its best to start a discussion by filing an issue for any contribution.

Building and Testing

If you want to develop within the repository, clone it, and run the following commands:

# Install requirements and setup envionment
source init.sh install

# Build and Test
./build.sh test

Related Links

  • Development workflow [TODO: Add wiki entry]

Hello World - Iris Classification Model

This sample here is a quick 5-minute introduction to using TensorFX. Here is the code for building a feed-forward neural network classification model for the iris dataset.

import tensorfx as tfx
import tensorfx.models.nn as nn

# Hyperparameters, training parameters, and data
args, job = nn.FeedForwardClassificationArguments.parse(parse_job=True)
dataset = tfx.data.CsvDataSet(args.data_schema,
                              train=args.data_train,
                              eval=args.data_eval,
                              metadata=args.data_metadata,
                              features=args.data_features)

# Instantiating the model builder
classification = nn.FeedForwardClassification(args, dataset)

# Training
trainer = tfx.training.ModelTrainer()
model = trainer.train(classification, job)

# Prediction
instances = [
  '6.3,3.3,6,2.5',   # virginica
  '4.4,3,1.3,0.2',   # setosa
  '6.1,2.8,4.7,1.2'  # versicolor
]
predictions = model.predict(instances)

Here's an outline steps to perform for basic usage of what TensorFX offers:

  1. Parse (or build) an Arguments object, usually from the command-line to define hyperparameters. This object corresponds to the kind of model you are training, so, FeedForwardClassificationArguments in this case.
  2. Create a DataSet to reference training and evaluation data, along with supporting configuration - namely - schema, metadata, and features (more on these below).
  3. Initialize the model builder - in this case FeedForwardClassification.
  4. Initialize the model trainer, and invoke train() which runs the training process to return a model.
  5. Load some instances you want to run through the model and call predict().

Schema - schema.yaml

The schema describes the structure of your data. This can be defined programmatically, but is conveniently expressible in declarative YAML form, and placed alongside training data.

fields:
- name: species
  type: discrete
- name: petal_length
  type: numeric
- name: petal_width
  type: numeric
- name: sepal_length
  type: numeric
- name: sepal_width
  type: numeric

Metadata - metadata.json

Metadata is the result of analyzing training data, based on type information in the schema. Iris is a tiny dataset, so metadata is readily producable using simple python code looping over the data. For real-world and large datasets, you'll find Spark and BigQuery (on Google Cloud Platform) as essential data processing runtimes. Stay tuned - TensorFX will provide support for these capabilities out of the box.

{
  "species": { "entries": ["setosa", "virginica", "versicolor"] },
  "petal_length": { "min": 4.3, "max": 7.9 },
  "petal_width": { "min": 2.0, "max": 4.4 },
  "sepal_length": { "min": 1.1, "max": 6.9 },
  "sepal_width": { "min": 0.1, "max": 2.5 }
}

Features - features.yaml

Like schema, features can also be defined programmatically, or expressed in YAML. Features describe the set of inputs that your models operate over, and how they are produced by applying transformations to the fields in your data. These transformations are turned into TensorFlow graph constructs and applied consistently to both training and prediction data.

In this particular example, the FeedForwardClassification model requires two features: X defining the values the model uses for producing inferences, and Y, the target label that the model is expected to predict which are defined as follows:

features:
- name: X
  type: concat
  features:
  - name: petal_width
    type: scale
  - name: petal_length
    type: scale
  - name: sepal_width
    type: log
  - name: sepal_length
    type: log
- name: Y
  type: target
  fields: species

Running the Model

The python code in the sample can be run directly, or using a train tool, as shown:

cd samples
tfx train \
  --module iris.trainer.main \
  --output /tmp/tensorfx/iris/csv \
  --data-train iris/data/train.csv \
  --data-eval iris/data/eval.csv \
  --data-schema iris/data/schema.yaml \
  --data-metadata iris/data/metadata.json \
  --data-features iris/features.yaml \
  --log-level-tensorflow ERROR \
  --log-level INFO \
  --batch-size 5 \
  --max-steps 2000 \
  --checkpoint-interval-secs 1 \
  --hidden-layers:1 20 \
  --hidden-layers:2 10

Once the training is complete, you can list the contents of the output directory. You should see the model (the prediction graph, and learnt variables) in the model subdirectory, alongside checkpoints, and summaries.

ls -R /tmp/tensorfx/iris/csv
checkpoints	job.yaml	model		summaries

/tmp/tensorfx/iris/csv/checkpoints:
checkpoint                             model.ckpt-2000.index
model.ckpt-1.data-00000-of-00001       model.ckpt-2000.meta
model.ckpt-1.index                     model.ckpt-2001.data-00000-of-00001
model.ckpt-1.meta                      model.ckpt-2001.index
model.ckpt-1562.data-00000-of-00001    model.ckpt-2001.meta
model.ckpt-1562.index                  model.ckpt-778.data-00000-of-00001
model.ckpt-1562.meta                   model.ckpt-778.index
model.ckpt-2000.data-00000-of-00001    model.ckpt-778.meta

/tmp/tensorfx/iris/csv/model:
saved_model.pb	variables

/tmp/tensorfx/iris/csv/model/variables:
variables.data-00000-of-00001	variables.index

/tmp/tensorfx/iris/csv/summaries:
eval		prediction	train

/tmp/tensorfx/iris/csv/summaries/eval:
events.out.tfevents.1488351760
events.out.tfevents.1488352853

/tmp/tensorfx/iris/csv/summaries/prediction:
events.out.tfevents.1488351765

/tmp/tensorfx/iris/csv/summaries/train:
events.out.tfevents.1488351760
events.out.tfevents.1488352852

Summaries are TensorFlow events logged during training. They can be observed while the training job is running (which is essential when running a long or real training job) to understand how your training is progressing, or how the model is converging (or not!).

tensorboard --logdir /tmp/tensorfx/iris/csv

This should bring up TensorBoard. Its useful to see the graph structure, metrics and other tensors that are automatically published.

Training Graph

Graphs in TensorBoard

Training Metrics -- Accuracy, Loss and Throughput

Metrics in TensorBoard

Model Variables -- Weights, Gradients, etc.

Watchin Learnt Variables

As you can see, the out-of-box model takes care of a number of details. The same code can be run on a single machine, or in a cluster (of course, iris is too simple of a problem to need that).

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].