Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save minesh1291/de8d5a6437e18bd8fa48c29f570d9598 to your computer and use it in GitHub Desktop.

Select an option

Save minesh1291/de8d5a6437e18bd8fa48c29f570d9598 to your computer and use it in GitHub Desktop.
Conversion of Keras/Tensorflow Probabilities to One Hot Vectors #python
# pred_batch shape is (N, CLASS_COUNT), where N is the batch size
# it is returned by Keras as a probabilities/logits
# this converts the probabilities to a 1 hot vector
pred_batch = model.predict_on_batch(image_batch)
pred_batch = (pred_batch == pred_batch.max(axis=1)).astype(int)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment