[Python] How do the SoftMax partial derivatives map to my Python code?

Discussão em 'Python' iniciado por Stack, Março 24, 2025.

  1. Stack

    Stack Membro Participativo

    The SoftMax function partial derivatives are defined as follows:

    S_ij * delta_jk - S_ij * S_ik


    Where S is the SoftMax function, i is the 0th axis index, j is the 1st axis index, and k is the corrected label.

    But how does this relate to the bellow Python code?

    import numpy as np

    softmax_output = np.array([0.7, 0.1, 0.2]).reshape(-1, 1)
    jacobian_matrix = np.diagflat(softmax_output)
    right = np.dot(softmax_output, softmax_output.T)
    result = jacobian_matrix - right

    Continue reading...

Compartilhe esta Página