y_conv = tf.matmul(h_fc1_drop, W_fc2) + b_fc2 # loss cross_entropy = tf.reduce_mean( tf.nn.softmax_cross_entropy_with_logits(labels=y_, logits=y_conv)) train_step = tf.train.AdamOptimizer(5e-3).minimize(cross_entropy) correct_prediction = tf.equal(tf.argmax(y_conv, 1), tf.argmax(y_, 1)) accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32)) # Get the mnist dataset (use tensorflow here) from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets("MNIST_data/", one_hot=True) with tf.Session() as sess: sess.run(tf.global_variables_initializer()) for i in range(200): print(i) batch = mnist.train.next_batch(100) if i % 5 == 0: train_accuracy = accuracy.eval(feed_dict={ x: batch[0], y_: batch[1], keep_prob: 1.0 }) print('step %d, trainning accuracy %g' % (i, train_accuracy)) train_step.run(feed_dict={x: batch[0], y_: batch[1], keep_prob: 0.5}) ans = accuracy.eval(feed_dict={ x: mnist.test.images,
""" import your model here """ import tensorwolf as tf """ your model should support the following code """ import numpy as np sess = tf.Session() # linear model W = tf.Variable([.5], dtype=tf.float32) b = tf.Variable([1.5], dtype=tf.float32) x = tf.placeholder(tf.float32) linear_model = W * x + b init = tf.global_variables_initializer() sess.run(init) ans = sess.run(linear_model, {x: [1, 2, 3, 4]}) assert np.array_equal(ans, [2, 2.5, 3, 3.5])