Git Product home page Git Product logo

ml-course1's People

Contributors

n-balakumaran avatar vijayinfi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ml-course1's Issues

Unable to restore the convnet model trained on MNIST

Hi,

I wrote below snippet for restoring model but I get error when I apply softmax over logits.
"ValueError: Argument must be a dense tensor: got shape [1, 128, 10], but wanted [1]."

with tf.Session() as sess:

meta_file = os.path.join(checkpoints_dir, 'mnist-convnet-419.meta')  # partially documented: saver.save stores this
saver = tf.train.import_meta_graph(meta_file, clear_devices=True)
saver.restore(sess, os.path.join(checkpoints_dir, 'mnist-convnet-419'))

X = sess.graph.get_tensor_by_name("data/X_placeholder:0")
Y = sess.graph.get_tensor_by_name("data/Y_placeholder:0")
dropout = sess.graph.get_tensor_by_name("dropout:0")

w = sess.graph.get_tensor_by_name("softmax_linear/weights:0")
b = sess.graph.get_tensor_by_name("softmax_linear/biases:0")
fc = sess.graph.get_tensor_by_name("fc/relu:0")
fc = tf.nn.dropout(fc, dropout, name='relu_dropout')

logits = tf.matmul(fc, w) + b


# test the model
n_batches = int(mnist.test.num_examples / BATCH_SIZE)
total_correct_preds = 0
for i in range(n_batches):
    X_batch, Y_batch = mnist.test.next_batch(BATCH_SIZE)
    logits_batch = sess.run([logits], feed_dict={X: X_batch, Y: Y_batch, dropout: DROPOUT})
    preds = tf.nn.softmax(logits_batch)
    correct_preds = tf.equal(tf.argmax(preds, 1), tf.argmax(Y_batch, 1))
    accuracy = tf.reduce_sum(tf.cast(correct_preds, tf.float32))
    total_correct_preds += sess.run(accuracy)

print("Accuracy {0}".format(total_correct_preds / mnist.test.num_examples))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.