Skip to content

Instantly share code, notes, and snippets.

@CMCDragonkai
Created September 4, 2018 05:41
Show Gist options
  • Select an option

  • Save CMCDragonkai/0f5bb84fb989c2b140fbf084bb1ebf3a to your computer and use it in GitHub Desktop.

Select an option

Save CMCDragonkai/0f5bb84fb989c2b140fbf084bb1ebf3a 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