Participer au site avec un Tip
Rechercher
 

Améliorations / Corrections

Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.

Emplacement :

Description des améliorations :

Vous êtes un professionnel et vous avez besoin d'une formation ? Deep Learning avec Python
et Keras et Tensorflow
Voir le programme détaillé
Module « scipy.special »

Fonction log_softmax - module scipy.special

Signature de la fonction log_softmax

def log_softmax(x, axis=None) 

Description

help(scipy.special.log_softmax)

Compute the logarithm of the softmax function.

In principle::

    log_softmax(x) = log(softmax(x))

but using a more accurate implementation.

Parameters
----------
x : array_like
    Input array.
axis : int or tuple of ints, optional
    Axis to compute values along. Default is None and softmax will be
    computed over the entire array `x`.

Returns
-------
s : ndarray or scalar
    An array with the same shape as `x`. Exponential of the result will
    sum to 1 along the specified axis. If `x` is a scalar, a scalar is
    returned.

Notes
-----
`log_softmax` is more accurate than ``np.log(softmax(x))`` with inputs that
make `softmax` saturate (see examples below).

.. versionadded:: 1.5.0

Examples
--------
>>> import numpy as np
>>> from scipy.special import log_softmax
>>> from scipy.special import softmax
>>> np.set_printoptions(precision=5)

>>> x = np.array([1000.0, 1.0])

>>> y = log_softmax(x)
>>> y
array([   0., -999.])

>>> with np.errstate(divide='ignore'):
...   y = np.log(softmax(x))
...
>>> y
array([  0., -inf])



Vous êtes un professionnel et vous avez besoin d'une formation ? Calcul scientifique
avec Python
Voir le programme détaillé