Skip to content

Commit 371863a

Browse files
committed
Fixes tensorflow#13: Fixed readme to use skflow.models.logistic_regerssion and also created example in examples/ folder with this code to make sure it runs.
1 parent bdb4470 commit 371863a

2 files changed

Lines changed: 34 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ iris = datasets.load_iris()
9696
def my_model(X, y):
9797
"""This is DNN with 10, 20, 10 hidden layers, and dropout of 0.5 probability."""
9898
layers = skflow.ops.dnn(X, [10, 20, 10], keep_prob=0.5)
99-
return skflow.ops.logistic_classifier(layers, y)
99+
return skflow.models.logistic_regression(layers, y)
100100

101101
classifier = skflow.TensorFlowEstimator(model_fn=my_model, n_classes=3)
102102
classifier.fit(iris.data, iris.target)

examples/iris_custom_model.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright 2015 Google Inc. 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+
import skflow
18+
from sklearn import datasets, metrics
19+
20+
iris = datasets.load_iris()
21+
22+
random.seed(42)
23+
24+
def my_model(X, y):
25+
"""This is DNN with 10, 20, 10 hidden layers, and dropout of 0.5 probability."""
26+
layers = skflow.ops.dnn(X, [10, 20, 10], keep_prob=0.5)
27+
return skflow.models.logistic_regression(layers, y)
28+
29+
classifier = skflow.TensorFlowEstimator(model_fn=my_model, n_classes=3)
30+
classifier.fit(iris.data, iris.target)
31+
score = metrics.accuracy_score(classifier.predict(iris.data), iris.target)
32+
print("Accuracy: %f" % score)
33+

0 commit comments

Comments
 (0)