Skip to content

Instantly share code, notes, and snippets.

@hadifar
Last active January 5, 2019 11:51
Show Gist options
  • Save hadifar/96096e3724a99b58d87b33a5c32cd042 to your computer and use it in GitHub Desktop.
Save hadifar/96096e3724a99b58d87b33a5c32cd042 to your computer and use it in GitHub Desktop.
# Feature columns describe how to use the input.
my_feature_columns = []
for key in iris_data.train_x.keys():
my_feature_columns.append(tf.feature_column.numeric_column(key=key))
# Build 2 hidden layer DNN with 10, 10 units respectively.
classifier = tf.estimator.DNNClassifier(
feature_columns=my_feature_columns,
# Two hidden layers of 10 nodes each.
hidden_units=[10, 10],
# The model must choose between 3 classes.
n_classes=3,
# The directory which model to be saved
model_dir='./tmp'
)
# Train the Model.
classifier.train(input_fn=iris_data.train_input_fn, steps=1000)
# Evaluate the model.
eval_result = classifier.evaluate(input_fn=iris_data.eval_input_fn)
print('\nTest set accuracy: {accuracy:0.3f}\n'.format(**eval_result))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment