Skip to content

Instantly share code, notes, and snippets.

@joeyism
Last active September 8, 2018 18:33
Show Gist options
  • Save joeyism/4476585056768e81562a0e7ee9c4188c to your computer and use it in GitHub Desktop.
Save joeyism/4476585056768e81562a0e7ee9c4188c to your computer and use it in GitHub Desktop.
import tensornets as nets
import tensorflow as tf
learning_rate = 0.00001
n_classes = 10
image_size = 224
inputs = tf.placeholder(tf.float32, [None, image_size, image_size, 3])
outputs = tf.placeholder(tf.float32, [None, n_classes])
vgg = nets.VGG19(inputs, is_training=True, classes=n_classes)
model = tf.identity(vgg, name='logits')
cost = tf.losses.softmax_cross_entropy(outputs, vgg)
optimizer = tf.train.AdamOptimizer(learning_rate=learning_rate).minimize(cost)
correct_pred = tf.equal(tf.argmax(model, 1), tf.argmax(outputs, 1))
accuracy = tf.reduce_mean(tf.cast(correct_pred, tf.float32))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment