Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 55e87f1

Browse files
committed
Merge branch 'master' into neural-translation
2 parents 9e35ac3 + 7cdfb0d commit 55e87f1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1472
-227
lines changed

.coveragerc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
branch = True
33

44
[report]
5-
omit = */tests/*
6-
5+
omit =
6+
*/tests/*
7+
*/ops/batch_norm_ops.py

.pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
ignore=tests
44

5-
disable=invalid-name,wildcard-import,too-many-arguments,attribute-defined-outside-init,no-member,too-many-instance-attributes,too-few-public-methods,import-error,super-on-old-class,fixme,protected-access,locally-disabled,cyclic-import,too-many-locals
5+
disable=invalid-name,wildcard-import,too-many-arguments,attribute-defined-outside-init,no-member,too-many-instance-attributes,too-few-public-methods,import-error,super-on-old-class,fixme,protected-access,locally-disabled,cyclic-import,too-many-locals,duplicate-code
66

77
dummy-variables-rgx=(unused|)_.*
88

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ cache:
1919
addons:
2020
apt:
2121
packages:
22-
- libatlas3gf-base
2322
- libatlas-dev
2423
- libblas-dev
2524
- liblapack-dev

README.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
[![Travis-CI Build Status](https://travis-ci.org/google/skflow.svg?branch=master)](https://travis-ci.org/google/skflow)
2-
[![Codecov Status](https://codecov.io/github/google/skflow/coverage.svg?precision=2)](https://codecov.io/github/google/skflow)
3-
[![License](https://img.shields.io/github/license/google/skflow.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)
4-
[![Join the chat at https://gitter.im/google/skflow](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/google/skflow?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
1+
[![Travis-CI Build Status](https://travis-ci.org/tensorflow/skflow.svg?branch=master)](https://travis-ci.org/tensorflow/skflow)
2+
[![Codecov Status](https://codecov.io/github/tensorflow/skflow/coverage.svg?precision=2)](https://codecov.io/github/tensorflow/skflow)
3+
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)
4+
[![Join the chat at https://gitter.im/tensorflow/skflow](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/tensorflow/skflow?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
55

66
# Scikit Flow
77

88
This is a simplified interface for TensorFlow, to get people started on predictive analytics and data mining.
99

10-
Why TensorFlow?
10+
Library covers variety of needs from linear models to *Deep Learning* applications like text and image understanding.
11+
12+
Why *TensorFlow*?
1113
* TensorFlow provides a good backbone for building different shapes of machine learning applications.
1214
* It will continue to evolve both in the distributed direction and as general pipelinining machinery.
1315

14-
Why Scikit Flow?
16+
Why *Scikit Flow*?
1517
* To smooth the transition from the Scikit Learn world of one-liner machine learning into the
1618
more open world of building different shapes of ML models. You can start by using fit/predict and slide into TensorFlow APIs as you are getting comfortable.
1719
* To provide a set of reference models that would be easy to integrate with existing code.
@@ -26,19 +28,20 @@ Support versions of dependencies:
2628
First, make sure you have TensorFlow and Scikit Learn installed, then just run:
2729

2830
```Bash
29-
pip install git+git://github.com/google/skflow.git
31+
pip install git+git://github.com/tensorflow/skflow.git
3032
```
3133

3234
## Tutorial
3335

3436
* [Introduction to Scikit Flow and why you want to start learning TensorFlow](https://medium.com/@ilblackdragon/tensorflow-tutorial-part-1-c559c63c0cb1)
3537
* [DNNs, custom model and Digit recognition examples](https://medium.com/@ilblackdragon/tensorflow-tutorial-part-2-9ffe47049c92)
38+
* [Categorical variables: One hot vs Distributed representation](https://medium.com/@ilblackdragon/tensorflow-tutorial-part-3-c5fc0662bc08)
3639
* More coming soon.
3740

3841
## Usage
3942

4043
Below are few simple examples of the API.
41-
For more examples, please see [examples](https://github.com/google/skflow/tree/master/examples).
44+
For more examples, please see [examples](https://github.com/tensorflow/skflow/tree/master/examples).
4245

4346
### General tips
4447

@@ -58,7 +61,7 @@ from sklearn import datasets, metrics
5861
iris = datasets.load_iris()
5962
classifier = skflow.TensorFlowLinearClassifier(n_classes=3)
6063
classifier.fit(iris.data, iris.target)
61-
score = metrics.accuracy_score(classifier.predict(iris.data), iris.target)
64+
score = metrics.accuracy_score(iris.target, classifier.predict(iris.data))
6265
print("Accuracy: %f" % score)
6366
```
6467

@@ -89,7 +92,7 @@ from sklearn import datasets, metrics
8992
iris = datasets.load_iris()
9093
classifier = skflow.TensorFlowDNNClassifier(hidden_units=[10, 20, 10], n_classes=3)
9194
classifier.fit(iris.data, iris.target)
92-
score = metrics.accuracy_score(classifier.predict(iris.data), iris.target)
95+
score = metrics.accuracy_score(iris.target, classifier.predict(iris.data))
9396
print("Accuracy: %f" % score)
9497
```
9598

@@ -110,7 +113,7 @@ def my_model(X, y):
110113

111114
classifier = skflow.TensorFlowEstimator(model_fn=my_model, n_classes=3)
112115
classifier.fit(iris.data, iris.target)
113-
score = metrics.accuracy_score(classifier.predict(iris.data), iris.target)
116+
score = metrics.accuracy_score(iris.target, classifier.predict(iris.data))
114117
print("Accuracy: %f" % score)
115118
```
116119

@@ -172,10 +175,10 @@ tensorboard --logdir=/tmp/tf_examples/my_model_1
172175
and follow reported url.
173176

174177
Graph visualization:
175-
![Text classification RNN Graph](https://raw.githubusercontent.com/google/skflow/master/docs/images/text_classification_rnn_graph.png)
178+
![Text classification RNN Graph](https://raw.githubusercontent.com/tensorflow/skflow/master/docs/images/text_classification_rnn_graph.png)
176179

177180
Loss visualization:
178-
![Text classification RNN Loss](https://raw.githubusercontent.com/google/skflow/master/docs/images/text_classification_rnn_loss.png)
181+
![Text classification RNN Loss](https://raw.githubusercontent.com/tensorflow/skflow/master/docs/images/text_classification_rnn_loss.png)
179182

180183
## More examples
181184

examples/README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,28 @@ Examples of Using skflow
44
* [Deep Neural Network Regression with Boston Data](boston.py)
55
* [Convolutional Neural Networks with Digits Data](digits.py)
66
* [Deep Neural Network Classification with Iris Data](iris.py)
7+
* [Deep Neural Network with Customized Decay Function](iris_custom_decay_dnn.py)
78
* [Building A Custom Model](iris_custom_model.py)
89
* [Building A Custom Model Using Multiple GPUs](multiple_gpu.py)
910
* [Using skflow with Pipeline](iris_with_pipeline.py)
1011
* [Example of saving and restoring models](iris_save_restore.py)
1112
* [Multi-output Deep Neural Network regression](multioutput_regression.py)
1213
* [Improving Performance Using Early Stopping with Iris Data](iris_early_stopping.py)
14+
* [Out-of-core Data Classification Using Dask](out_of_core_data_classification.py)
15+
16+
17+
Image classification
18+
--------------------
19+
20+
* [Convolutional Neural Networks on MNIST Data](mnist.py)
21+
* [Deep Residual Networks on MNIST Data](resnet.py)
1322

1423

1524
Text classification
1625
-------------------
1726

18-
* [Text Classification Using Recurrent Neural Networks on Words](text_classification.py)
27+
* [Text Classification Using Recurrent Neural Networks on Words](text_classification.py) (See also [Simplified Version Using Built-in RNN Model](text_classification_builtin_rnn_model.py))
1928
* [Text Classification Using Convolutional Neural Networks on Words](text_classification_cnn.py)
2029
* [Text Classification Using Recurrent Neural Networks on Characters](text_classification_character_rnn.py)
2130
* [Text Classification Using Convolutional Neural Networks on Characters](text_classification_character_cnn.py)
31+

examples/boston.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,22 @@
2525
boston = datasets.load_boston()
2626
X, y = boston.data, boston.target
2727

28-
# Scale data to 0 mean and unit std dev.
29-
scaler = preprocessing.StandardScaler()
30-
X = scaler.fit_transform(X)
31-
3228
# Split dataset into train / test
3329
X_train, X_test, y_train, y_test = cross_validation.train_test_split(X, y,
3430
test_size=0.2, random_state=42)
3531

32+
# scale data (training set) to 0 mean and unit Std. dev
33+
scaler = preprocessing.StandardScaler()
34+
X_train = scaler.fit_transform(X_train)
35+
3636
# Build 2 layer fully connected DNN with 10, 10 units respecitvely.
3737
regressor = skflow.TensorFlowDNNRegressor(hidden_units=[10, 10],
3838
steps=5000, learning_rate=0.1, batch_size=1)
3939

40-
# Fit and predict.
40+
# Fit
4141
regressor.fit(X_train, y_train)
42-
score = metrics.mean_squared_error(regressor.predict(X_test), y_test)
42+
43+
# Predict and score
44+
score = metrics.mean_squared_error(regressor.predict(scaler.fit_transform(X_test)), y_test)
45+
4346
print('MSE: {0:f}'.format(score))

examples/digits.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818

1919
import skflow
2020

21-
random.seed(42)
22-
2321
# Load dataset and split it into train / test subsets.
2422

2523
digits = datasets.load_digits()
@@ -42,5 +40,5 @@ def conv_model(X, y):
4240
steps=500, learning_rate=0.05,
4341
batch_size=128)
4442
classifier.fit(X_train, y_train)
45-
score = metrics.accuracy_score(classifier.predict(X_test), y_test)
43+
score = metrics.accuracy_score(y_test, classifier.predict(X_test))
4644
print('Accuracy: {0:f}'.format(score))

examples/iris.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727

2828
# Build 3 layer DNN with 10, 20, 10 units respecitvely.
2929
classifier = skflow.TensorFlowDNNClassifier(hidden_units=[10, 20, 10],
30-
n_classes=3, steps=200)
30+
n_classes=3, steps=200)
3131

3232
# Fit and predict.
3333
classifier.fit(X_train, y_train)
34-
score = metrics.accuracy_score(classifier.predict(X_test), y_test)
34+
score = metrics.accuracy_score(y_test, classifier.predict(X_test))
3535
print('Accuracy: {0:f}'.format(score))
3636

examples/iris_custom_decay_dnn.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Copyright 2015-present Scikit Flow Authors. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import random
16+
17+
from sklearn import datasets, metrics
18+
from sklearn.cross_validation import train_test_split
19+
20+
import skflow
21+
import tensorflow as tf
22+
23+
24+
random.seed(42)
25+
26+
iris = datasets.load_iris()
27+
X_train, X_test, y_train, y_test = train_test_split(iris.data,
28+
iris.target,
29+
test_size=0.2,
30+
random_state=42)
31+
# setup exponential decay function
32+
def exp_decay(global_step):
33+
return tf.train.exponential_decay(
34+
learning_rate=0.1, global_step=global_step,
35+
decay_steps=100, decay_rate=0.001)
36+
37+
# use customized decay function in learning_rate
38+
classifier = skflow.TensorFlowDNNClassifier(hidden_units=[10, 20, 10],
39+
n_classes=3, steps=800,
40+
learning_rate=exp_decay)
41+
classifier.fit(X_train, y_train)
42+
score = metrics.accuracy_score(y_test, classifier.predict(X_test))

examples/iris_custom_model.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@
2424
random.seed(42)
2525

2626
def my_model(X, y):
27-
"""This is DNN with 10, 20, 10 hidden layers, and dropout of 0.5 probability."""
28-
layers = skflow.ops.dnn(X, [10, 20, 10], keep_prob=0.5)
27+
"""This is DNN with 10, 20, 10 hidden layers, and dropout of 0.9 probability."""
28+
layers = skflow.ops.dnn(X, [10, 20, 10], keep_prob=0.9)
2929
return skflow.models.logistic_regression(layers, y)
3030

31-
classifier = skflow.TensorFlowEstimator(model_fn=my_model, n_classes=3)
31+
classifier = skflow.TensorFlowEstimator(model_fn=my_model, n_classes=3,
32+
steps=1000)
3233
classifier.fit(X_train, y_train)
33-
score = metrics.accuracy_score(classifier.predict(X_test), y_test)
34+
score = metrics.accuracy_score(y_test, classifier.predict(X_test))
3435
print('Accuracy: {0:f}'.format(score))
3536

0 commit comments

Comments
 (0)