[Python] How does argmax work when given a 3d tensor - tensorflow

Discussão em 'Python' iniciado por Stack, Setembro 3, 2025.

  1. Stack

    Stack Membro Participativo

    I was wondering how does argmax work when given a 3D tensor. I know what happens when it has a 2D tesnor but 3D is confusing me a lot.

    Example:

    import tensorflow as tf
    import numpy as np

    sess = tf.Session()

    coordinates = np.random.randint(0, 100, size=(3, 3, 2))
    coordinates
    Out[20]:
    array([[[15, 23],
    [ 3, 1],
    [80, 56]],
    [[98, 95],
    [97, 82],
    [10, 37]],
    [[65, 32],
    [25, 39],
    [54, 68]]])
    sess.run([tf.argmax(coordinates, axis=1)])
    Out[21]:
    [array([[2, 2],
    [0, 0],
    [0, 2]], dtype=int64)]

    Continue reading...

Compartilhe esta Página