<jupyter_start><jupyter_text>Trial 3: TensorFlowSmall experiment to familiarize myself with TensorFlow.<jupyter_code>import tensorflow as tf<jupyter_output><empty_output><jupyter_text>Data<jupyter_code>from tensorflow.examples.tutorials.mnist import input_data
import os
folder = os.path.join('..', 'data', 'mnist')
mnist = input_data.read_data_sets(folder, one_hot=True)<jupyter_output><empty_output><jupyter_text>Model<jupyter_code>x = tf.placeholder(tf.float32, [None, 784])
W = tf.Variable(tf.zeros([784, 10]))
b = tf.Variable(tf.zeros([10]))
y = tf.nn.softmax(tf.matmul(x, W) + b)<jupyter_output><empty_output><jupyter_text>Training<jupyter_code>y_ = tf.placeholder(tf.float32, [None, 10])
cross_entropy = tf.reduce_mean(-tf.reduce_sum(y_ * tf.log(y), reduction_indices=[1]))
train_step = tf.train.GradientDescentOptimizer(0.5).minimize(cross_entropy)

init = tf.initialize_all_variables()
sess = tf.Session()
sess.run(init)

for i in range(1000):
    batch_xs, batch_ys = mnist.train.next_batch(100)
    sess.run(train_step, feed_dict={x: batch_xs, y_: batch_ys})<jupyter_output><empty_output><jupyter_text>Evaluation<jupyter_code>correct_prediction = tf.equal(tf.argmax(y,1), tf.argmax(y_,1))
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
print(sess.run(accuracy, feed_dict={x: mnist.test.images, y_: mnist.test.labels}))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15083393763596809, 'fraction_numerical': 0.022480058013052938, 'mean_word_length': 8.65034965034965, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '183041', 'license': 'MIT', 'n_tokens_mistral': 572, 'n_tokens_neox': 543, 'n_words': 72, 'path': 'trials/3_tensorflow.ipynb', 'repo_name': 'Gxqiang/cnn_graph', 'size': '1379'}