()
| 6 | |
| 7 | |
| 8 | def main(): |
| 9 | logging.getLogger().setLevel(logging.INFO) |
| 10 | |
| 11 | iris = learn.datasets.load_iris() |
| 12 | |
| 13 | X_train, X_test, y_train, y_test = train_test_split(iris.data, iris.target, test_size=0.2, random_state=42) |
| 14 | |
| 15 | feature_columns = [tf.contrib.layers.real_valued_column("", dimension=4)] |
| 16 | |
| 17 | # Build a neural network with 3 hidden layers: 10, 20, 10 units respectively |
| 18 | classifier = learn.DNNClassifier(hidden_units=[10, 20, 10], n_classes=3, feature_columns=feature_columns) |
| 19 | |
| 20 | classifier.fit(X_train, y_train, steps=2000) |
| 21 | |
| 22 | score = metrics.accuracy_score(y_test, classifier.predict(X_test)) |
| 23 | |
| 24 | print("Accuracy: {0:f}".format(score)) |
| 25 | |
| 26 | |
| 27 | if __name__ == '__main__': |
no test coverage detected