Created
September 4, 2018 23:45
-
-
Save joeyism/4580996d1db5902510a25ae07decd4d1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pretrained | |
import tensorflow as tf | |
n_classes = 10 | |
learning_rate = 0.00001 | |
conv5 = tf.layers.flatten(pretrained.maxpool5) | |
weights = tf.Variable(tf.zeros([9216, n_classes]), name="output_weight") | |
bias = tf.Variable(tf.truncated_normal([n_classes]), name="output_bias") | |
model = tf.matmul(conv5, weights) + bias | |
outputs = tf.placeholder(tf.float32, [None, n_classes]) | |
cost = tf.losses.softmax_cross_entropy(outputs, model) | |
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