diff options
author | Martin Wicke <wicke@google.com> | 2017-03-23 12:31:16 -0800 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2017-03-23 13:44:29 -0700 |
commit | bc456e361d49d1d89a74b80060c70efb51fd7d87 (patch) | |
tree | 825e04287f1e2d2ac098ca3f0fdd4e361aefd68c /tensorflow/examples/learn | |
parent | 8ca071456537e6c96ae8896c2a20b1f08b0e59d3 (diff) |
Merge changes from github.
Change: 151046259
Diffstat (limited to 'tensorflow/examples/learn')
-rw-r--r-- | tensorflow/examples/learn/README.md | 2 | ||||
-rw-r--r-- | tensorflow/examples/learn/boston.py | 9 | ||||
-rw-r--r-- | tensorflow/examples/learn/iris.py | 4 | ||||
-rw-r--r-- | tensorflow/examples/learn/text_classification.py | 3 |
4 files changed, 11 insertions, 7 deletions
diff --git a/tensorflow/examples/learn/README.md b/tensorflow/examples/learn/README.md index b36986855f..37157fc296 100644 --- a/tensorflow/examples/learn/README.md +++ b/tensorflow/examples/learn/README.md @@ -1,7 +1,7 @@ # TF Learn Examples Learn is a high-level API for TensorFlow that allows you to create, -train, and use deep learning models easily. See the [Quickstart tutorial](../../g3doc/tutorials/tflearn/index.md) +train, and use deep learning models easily. See the [Quickstart tutorial](https://www.tensorflow.org/get_started/tflearn) for an introduction to the API. To run most of these examples, you need to install the `scikit learn` library (`sudo pip install sklearn`). diff --git a/tensorflow/examples/learn/boston.py b/tensorflow/examples/learn/boston.py index 2986ff9106..19cfdee513 100644 --- a/tensorflow/examples/learn/boston.py +++ b/tensorflow/examples/learn/boston.py @@ -16,19 +16,22 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -from sklearn import cross_validation + +from sklearn import datasets +from sklearn import model_selection from sklearn import metrics from sklearn import preprocessing + import tensorflow as tf def main(unused_argv): # Load dataset - boston = tf.contrib.learn.datasets.load_dataset('boston') + boston = datasets.load_boston() x, y = boston.data, boston.target # Split dataset into train / test - x_train, x_test, y_train, y_test = cross_validation.train_test_split( + x_train, x_test, y_train, y_test = model_selection.train_test_split( x, y, test_size=0.2, random_state=42) # Scale data (training set) to 0 mean and unit standard deviation. diff --git a/tensorflow/examples/learn/iris.py b/tensorflow/examples/learn/iris.py index 7b65eb521a..ec2aa9b573 100644 --- a/tensorflow/examples/learn/iris.py +++ b/tensorflow/examples/learn/iris.py @@ -17,7 +17,7 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function - +from sklearn import datasets from sklearn import metrics from sklearn import model_selection @@ -26,7 +26,7 @@ import tensorflow as tf def main(unused_argv): # Load dataset. - iris = tf.contrib.learn.datasets.load_dataset('iris') + iris = datasets.load_iris() x_train, x_test, y_train, y_test = model_selection.train_test_split( iris.data, iris.target, test_size=0.2, random_state=42) diff --git a/tensorflow/examples/learn/text_classification.py b/tensorflow/examples/learn/text_classification.py index c3d00a11b9..7e10014c39 100644 --- a/tensorflow/examples/learn/text_classification.py +++ b/tensorflow/examples/learn/text_classification.py @@ -24,6 +24,7 @@ import numpy as np import pandas from sklearn import metrics import tensorflow as tf +from tensorflow.contrib.layers.python.layers import encoders learn = tf.contrib.learn @@ -37,7 +38,7 @@ n_words = 0 def bag_of_words_model(features, target): """A bag-of-words model. Note it disregards the word order in the text.""" target = tf.one_hot(target, 15, 1, 0) - features = tf.contrib.layers.bow_encoder( + features = encoders.bow_encoder( features, vocab_size=n_words, embed_dim=EMBEDDING_SIZE) logits = tf.contrib.layers.fully_connected(features, 15, activation_fn=None) loss = tf.contrib.losses.softmax_cross_entropy(logits, target) |