Skip to main content
. 2025 Apr 29;25(9):2793. doi: 10.3390/s25092793
Algorithm 3 The proposed Softmax function.
Require:  y(y{y0,,yJ1})
Ensure:  O(O{O0,,OJ1})
  •   1:

    for  (k=0;k<J;k++)  do

  •   2:

        Ok=0

  •   3:

    end for

  •   4:

    sum=0,check=0

  •   5:

    for  (k=0;k<J;k++)  do

  •   6:

        Ok=exp(yk)

  •   7:

        sum=sum+Ok

  •   8:

    end for

  •   9:

    if  (k!=J)  then

  • 10:

        exit(1);

  • 11:

    end if

  • 12:

    for  (k=0;k<J;k++)  do

  • 13:

        Ok=exp(yk)/sum

  • 14:

        check=check+Ok

  • 15:

    end for

  • 16:

    if  (k!=J)  then

  • 17:

        exit(1);

  • 18:

    end if

  • 19:

    if  (check!=1)  then

  • 20:

        exit(1);

  • 21:

    end if