How do you decode vibrant shortcuts in Tensorflow?

I looked, but it seems I can’t find examples of how to decode or convert back to a single whole from a single hot value in TensorFlow.

I used tf.one_hotand was able to train my model, but got a little confused about how to understand the brand after my classification. My data is uploaded through the file TFRecordsI created. I was thinking about storing a text label in a file, but could not get it to work. It seemed that it TFRecordscould not store the text string, or maybe I was wrong.

+4
source share
2 answers

, tf.argmax. 1 0 s, , .

index = tf.argmax(one_hot_vector, axis=0)

batch_size * num_classes axis=1, batch_size * 1.

+10

batch_size num_classes, , , tf.argmax() :

BATCH_SIZE = 3
NUM_CLASSES = 4
one_hot_encoded = tf.constant([[0, 1, 0, 0],
                               [1, 0, 0, 0],
                               [0, 0, 0, 1]])

# Compute the argmax across the columns.
decoded = tf.argmax(one_hot_encoded, axis=1)

# ...
print sess.run(decoded)  # ==> array([1, 0, 3])
+7

Source: https://habr.com/ru/post/1665353/


All Articles