Skip to content

Instantly share code, notes, and snippets.

(train_images, train_labels, test_images, test_labels, mean_image) = cifar_data_loader.load_data()
print(mean_image.shape) #32x32x3
correct_prediction = tf.equal(labels, tf.argmax(predictions, 1, output_type=tf.int32))
cost = tf.reduce_mean(tf.nn.sparse_softmax_cross_entropy_with_logits(logits=logits, labels=labels))
layer1_weights = tf.get_variable("layer1_weights", [3, 3, 3, 64], initializer=tf.contrib.layers.variance_scaling_initializer())
input = tf.placeholder(tf.float32, shape=(None, 32, 32, 3)) #Input is of size 32x32x3 (RGB images)
labels = tf.placeholder(tf.int32, shape=(None), name="labels") #Labels are single integers (tf.int32)
import tensorflow as tf
import numpy as np
import cifar_data_loader
(train_images, train_labels, test_images, test_labels, mean_image) = cifar_data_loader.load_data()
print(train_images.shape)
print(train_labels.shape)
print(test_images.shape)
print(test_labels.shape)
c, acc = session.run(['cost:0', 'accuracy:0'], feed_dict=feed_dict)
input = graph.get_tensor_by_name("input:0")
labels = graph.get_tensor_by_name("labels:0")
saver = tf.train.import_meta_graph('/tmp/vggnet/vgg_net.ckpt.meta')
saver.restore(session, '/tmp/vggnet/vgg_net.ckpt')
import tensorflow as tf
import numpy as np
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets('MNIST_data', one_hot=True)
test_images = np.reshape(mnist.test.images, (-1, 28, 28, 1))
test_labels = mnist.test.labels
graph = tf.Graph()
with tf.Session(graph=graph) as session: