• Stars
    star
    301
  • Rank 137,612 (Top 3 %)
  • Language
    C
  • License
    Apache License 2.0
  • Created over 7 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Minimal numerical computation library with TensorFlow APIs

MiniFlow

Introduction

MiniFlow is the numerical computation library which implements TensorFlow APIs.

  • Support math calculations and composited operations
  • Support automatic partial derivative and chain rule
  • Support operations in C++/Python backends with swig
  • Support platforms like Linux/MacOS/Windows/Raspbian
  • Support imperative and declarative computations
  • Support the compatiable APIs with TensorFlow

Installation

Install with pip.

pip install miniflow

Or run with docker.

docker run -it tobegit3hub/miniflow bash

Usage

MiniFlow has compatiable APIs with TensorFlow and please refer to examples for more usage.

Basic operations

Run with TensorFlow.

import tensorflow as tf

sess = tf.Session()

hello = tf.constant("Hello, TensorFlow!")
sess.run(hello)
# "Hello, TensorFlow!"

a = tf.constant(10)
b = tf.constant(32)
sess.run(a + b)
# 42

Run with MiniFlow.

import miniflow as tf

sess = tf.Session()

hello = tf.constant("Hello, MiniFlow!")
sess.run(hello)
# "Hello, MiniFlow!"

a = tf.constant(10)
b = tf.constant(32)
sess.run(a + b)
# 42

Use placeholder

Run with TensorFlow.

import tensorflow as tf

sess = tf.Session()

a = tf.placeholder(tf.float32)
b = tf.constant(32.0)
sess.run(a + b, feed_dict={a: 10})
sess.run(a + b, feed_dict={a.name: 10})
# 42.0

Run with MiniFlow.

import miniflow as tf

sess = tf.Session()

a = tf.placeholder(tf.float32)
b = tf.constant(32.0)
sess.run(a + b, feed_dict={a: 10})
sess.run(a + b, feed_dict={a.name: 10})
# 42.0

Linear model

Run with TensorFlow.

def linear_regression():
  epoch_number = 30
  learning_rate = 0.01
  train_features = [1.0, 2.0, 3.0, 4.0, 5.0]
  train_labels = [10.0, 20.0, 30.0, 40.0, 50.0]

  weights = tf.Variable(0.0)
  bias = tf.Variable(0.0)
  x = tf.placeholder(tf.float32)
  y = tf.placeholder(tf.float32)

  predict = weights * x + bias
  loss = tf.square(y - predict)
  sgd_optimizer = tf.train.GradientDescentOptimizer(learning_rate)
  train_op = sgd_optimizer.minimize(loss)

  with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())

    for epoch_index in range(epoch_number):
      # Take one sample from train dataset
      sample_number = len(train_features)
      train_feature = train_features[epoch_index % sample_number]
      train_label = train_labels[epoch_index % sample_number]

      # Update model variables and print loss
      sess.run(train_op, feed_dict={x: train_feature, y: train_label})
      loss_value = sess.run(loss, feed_dict={x: 1.0, y: 10.0})
      print("Epoch: {}, loss: {}, weight: {}, bias: {}".format(
          epoch_index, loss_value, sess.run(weights), sess.run(bias)))

Run with MiniFlow.

def linear_regression():
  epoch_number = 30
  learning_rate = 0.01
  train_features = [1.0, 2.0, 3.0, 4.0, 5.0]
  train_labels = [10.0, 20.0, 30.0, 40.0, 50.0]

  weights = tf.Variable(0.0)
  bias = tf.Variable(0.0)
  x = tf.placeholder(tf.float32)
  y = tf.placeholder(tf.float32)

  predict = weights * x + bias
  loss = tf.square(y - predict)
  sgd_optimizer = tf.train.GradientDescentOptimizer(learning_rate)
  train_op = sgd_optimizer.minimize(loss)

  with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())

    for epoch_index in range(epoch_number):
      # Take one sample from train dataset
      sample_number = len(train_features)
      train_feature = train_features[epoch_index % sample_number]
      train_label = train_labels[epoch_index % sample_number]

      # Update model variables and print loss
      sess.run(train_op, feed_dict={x: train_feature, y: train_label})
      loss_value = sess.run(loss, feed_dict={x: 1.0, y: 10.0})
      print("Epoch: {}, loss: {}, weight: {}, bias: {}".format(
          epoch_index, loss_value, sess.run(weights), sess.run(bias)))

The computed gradient and the variables of the model are accurate.

Performance

We have more performance tests in benchmark.

Contribution

GitHub issues and pull-requests are highly appreciated and feel free to make your contribution.

Release to upload the official python package of miniflow in pypi.

python setup.py sdist upload

python setup.py sdist --format=gztar
twine upload dist/miniflow-x.x.x.tar.gz

More Repositories

1

seagull

Friendly Web UI to manage and monitor docker
JavaScript
1,934
star
2

tensorflow_template_application

TensorFlow template application for deep learning
Python
1,869
star
3

advisor

Open-source implementation of Google Vizier for hyper parameters tuning
Jupyter Notebook
1,542
star
4

understand_linux_process

The open-source ebook of Understand Linux Process
Dockerfile
996
star
5

simple_tensorflow_serving

Generic and easy-to-use serving service for machine learning models
JavaScript
757
star
6

ml_implementation

Implementation of Machine Learning Algorithms
Python
389
star
7

lambda-docker

Event-driven code runtime like AWS Lambda service
Python
302
star
8

ceph_from_scratch

The practical book about ceph
Dockerfile
153
star
9

tensorflow_examples

TensorFlow Example Projects
Python
140
star
10

deep_image_model

Deep convolution/recurrent neural network project with TensorFlow
Python
100
star
11

openmldb-chatgpt-plugin

The ChatGPT plugin to enhance OpenMLDB.
Python
51
star
12

tobe-algorithm-manual

Tobe Algorithm Manual
Python
49
star
13

deep_q

Deep reinforcement learning with TensorFlow
Python
47
star
14

pirate

Private admin dashboard for docker distribution
Go
42
star
15

openspark

The out-of-the-box environment to for Hadoop/Spark applications
Dockerfile
39
star
16

tftvm

TensorFlow and TVM integration
C++
38
star
17

code_examples

The code for computer science
ANTLR
35
star
18

understand_linux_process_examples

Examples of Understand Linux Process
Go
34
star
19

enas_model

Automatically build the deep learning models with ENAS
Python
30
star
20

mycomputer

Share your enviable life
Go
27
star
21

tfmodel

Statically and dynamically inspect tool for TensorFlow models
Python
24
star
22

ceph-web

Web based management tool for ceph
Go
21
star
23

harbor-py

The missing harbor python SDK
Python
20
star
24

auto_imgaug

Automatical image augment with heuristic machine learning models
Python
18
star
25

mirror-dockerhub

Tools to mirror container images from docker hub
Shell
14
star
26

osop

OpenStack Operation automatical toolkits
Shell
13
star
27

hotpatch

Apply hot patches for running processes without restarting
C++
12
star
28

tuning_game

The hyper-parameters tuning and black box optimization games
Python
12
star
29

tensorflow_capsnet

TensorFlow implementation of CapsNet
Python
10
star
30

hplearn

High performance machine learning system
C++
8
star
31

gitsql

Query Git with SQL
Python
7
star
32

translate

Command-line translate tool, supported by Youdao
Ruby
6
star
33

tf_progress

Easy-to-use library for logging training progress of TensorFlow
Python
5
star
34

failover_paper

The paper of failover test framework for distributed system
4
star
35

nmenu

Customized Ncurses Menu Toolkit
Shell
2
star
36

openkube

The container with Kubernetes tools.
Dockerfile
2
star
37

NotATop

3D Android game of spinning top
Java
2
star
38

painter

The painter service to construct machine learning models easily
HTML
2
star
39

sparksql-magic

The notebook magic function for SparkSQL
Jupyter Notebook
2
star
40

PortableOpenMLDB

The portable OpenMLDB cluster which can be run anywhere without installation.
Shell
2
star
41

PyCss

Write CSS in pythonic way
Python
2
star
42

openmldb_lab

Enhanced web service for OpenMLDB
Vue
1
star
43

docs-project

The docs project for any project
1
star
44

PutsColor

The maven project to System.out.println colorful message easily
Java
1
star
45

hotdog-not-hotdog-app

Hot dog or not hot dog application with machine learning
Python
1
star
46

cmake_redis

CMake support for redis
Shell
1
star
47

android_control

Android control program with adb debugger
Python
1
star
48

rbac_book

The RBAC book about authentication and authorization
1
star
49

Childhood

The HTML5 video website to remind you of childhood
JavaScript
1
star
50

pm_simulator

PM(Project Manager) Simulator.
Python
1
star
51

mplayer

Android controller for embedded devices.
C
1
star