Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tf.argmax() vs tf.arg_max() in TensorFlow

It seems tf.argmax() and tf.arg_max() are doing the same thing for outputting the indies of the biggest element in matrix.

https://www.tensorflow.org/api_docs/python/tf/argmax https://www.tensorflow.org/api_docs/python/tf/arg_max

Why does TensorFlow have two APIs for this?

like image 437
Elsa Lin Avatar asked Mar 10 '23 20:03

Elsa Lin


1 Answers

The following is the source code of argmax (from https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/ops/math_ops.py).

# pylint: disable=redefined-builtin
# TODO(aselle): deprecate arg_max
def argmax(input, axis=None, name=None, dimension=None):
  if dimension is not None:
    if axis is not None:
      raise ValueError("Cannot specify both 'axis' and 'dimension'")
    axis = dimension
  elif axis is None:
    axis = 0
  return gen_math_ops.arg_max(input, axis, name)

As you can see, argmax is using arg_max inside. Also from the code, I recommend using argmax because arg_max could be deprecated soon.

like image 157
0Tech Avatar answered Mar 21 '23 04:03

0Tech