Brian Phiri
Brian Phiri

Reputation: 154

tensorfllow prediction and label

Hey i have built a neural network in tensor flow that i want to use to classify sounds, I would like to see the results of the prediction (its label and scores for the labels)

I am using this line to get the scores

values, indices = tf.nn.top_k(x,10) //where x is the input

and with this i am able to get the scores but not the associated labels is there anything i can append to this or labels i have to define to map the scores to the labels?

Upvotes: 0

Views: 604

Answers (1)

Jimmy Tran
Jimmy Tran

Reputation: 361

You can get your predictions and labels by retrieving the output of sess.run.

x = tf.placeholder(...) # x inputs
y_true = tf.placeholder(...) # labels

logits = ... # neural network model

predictions = tf.nn.softmax(logits) # prediction tensor

init_op = tf.initialize_all_variables()

with tf.Session() as sess:
    sess.run(init_op)

    # get run outputs
    pred, labels = sess.run([predictions, y_true],
                            feed_dict={x: x_inputs, y_true: y_inputs) 

# do something with the outputs
print labels
pd.Dataframe(data=pred)

Upvotes: 1

Related Questions