在TensorFlow中tf.argmax()vs tf.arg_max()

Els*_*Lin 4 python tensorflow

这似乎tf.argmax()tf.arg_max()正在做同样的事情在矩阵输出的最大元素的印度.

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

为什么TensorFlow有两个API?

小智 7

以下是argmax(来自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)
Run Code Online (Sandbox Code Playgroud)

如你所见,argmax正在使用arg_max内部.同样来自代码,我建议使用argmax因为arg_max可能很快就会被弃用.