[Python] What is the correct NumPy representation of a row vector for gradients

Discussão em 'Python' iniciado por Stack, Novembro 26, 2025.

  1. Stack

    Stack Membro Participativo

    I am doing an assignment on matrices and gradients, where the final answer must be expressed as a row vector.

    vr = np.array([1, 2, 3])
    vrr = np.array([[1, 2, 3]])


    Mathematically, a row vector should be a 1×3 matrix, so the shape (1,3) seems to match that idea. However, NumPy treats (3,) as a 1D array, and many operations, like dot products and gradients, seem to work with this form as well.

    What I want to clarify:


    1. Which of these is the true mathematical row vector?


    2. Which one should I use when a question explicitly asks for a row vector gradient?


    3. Is using shape (3,) mathematically ambiguous compared to (1,3)?

    Continue reading...

Compartilhe esta Página