Making predictions with a TensorFlow model

前端 未结 4 1150
天命终不由人
天命终不由人 2020-12-01 00:53

I followed the given mnist tutorials and was able to train a model and evaluate its accuracy. However, the tutorials don\'t show how to make predictions given a model. I\'m

4条回答
  •  Happy的楠姐
    2020-12-01 01:10

    In the "Deep MNIST for Experts" example, see this line:

    We can now implement our regression model. It only takes one line! We multiply the vectorized input images x by the weight matrix W, add the bias b, and compute the softmax probabilities that are assigned to each class.

    y = tf.nn.softmax(tf.matmul(x,W) + b)
    

    Just pull on node y and you'll have what you want.

    feed_dict = {x: [your_image]}
    classification = tf.run(y, feed_dict)
    print classification
    

    This applies to just about any model you create - you'll have computed the prediction probabilities as one of the last steps before computing the loss.

提交回复
热议问题