Professional Documents
Culture Documents
py
import pandas as pd
import tensorflow as tf
def _parse_line(line):
# Decode the line into its fields
return features, label
create_train_test2.py
import sys
import random
import argparse
import shutil
import sys
import tensorflow as tf
import wine_data2
parser = argparse.ArgumentParser():
'Base directory for the model.',
'Number of training epochs.',
'The number of training epochs to run between evaluations.',
'Number of examples per batch.',
'Path to the training data.',
'Path to the test data.'
optimizer = tf.train.AdagradOptimizer(learning_rate=0.01)
train_op = optimizer.minimize(loss, global_step=tf.train.get_global_step())
return tf.estimator.EstimatorSpec(mode, loss=loss, train_op=train_op)
def main(argv):
args = parser.parse_args(argv[1:])
# Fetch the data
(train_x, train_y), (test_x, test_y) = wine_data2.load_data('quality',
FLAGS.train_data, FLAGS.test_data)
classifier = tf.estimator.Estimator
# Train the Model.
# Evaluate the model.
# Generate predictions from the model
confusion_matrix = tf.confusion_matrix(test_y, p_classes)
if __name__ == '__main__':
tf.logging.set_verbosity(tf.logging.INFO)
FLAGS, unparsed = parser.parse_known_args()
tf.app.run(main=main, argv=[sys.argv[0]] + unparsed)