Skip to content

Instantly share code, notes, and snippets.

@hsiaoer
Created March 16, 2018 16:36
Show Gist options
  • Save hsiaoer/acd9209f471dc836ca221834aa12a6c4 to your computer and use it in GitHub Desktop.
Save hsiaoer/acd9209f471dc836ca221834aa12a6c4 to your computer and use it in GitHub Desktop.
def model_fn(features, labels, mode, params):
...
logits = model(image, training=False)
predictions = {
'classes': tf.argmax(logits, axis=1),
'probabilities': tf.nn.softmax(logits, name='softmax_tensor'),
}
if mode == tf.estimator.ModeKeys.PREDICT:
return tf.estimator.EstimatorSpec(
mode=tf.estimator.ModeKeys.PREDICT,
predictions=predictions,
export_outputs={
'classify': tf.estimator.export.PredictOutput(predictions)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment