Vous êtes un professionnel et vous avez besoin d'une formation ?
Programmation Python
Les fondamentaux
Voir le programme détaillé
Module « numpy »
Signature de la fonction unstack
def unstack(x, /, *, axis=0)
Description
help(numpy.unstack)
Split an array into a sequence of arrays along the given axis.
The ``axis`` parameter specifies the dimension along which the array will
be split. For example, if ``axis=0`` (the default) it will be the first
dimension and if ``axis=-1`` it will be the last dimension.
The result is a tuple of arrays split along ``axis``.
.. versionadded:: 2.1.0
Parameters
----------
x : ndarray
The array to be unstacked.
axis : int, optional
Axis along which the array will be split. Default: ``0``.
Returns
-------
unstacked : tuple of ndarrays
The unstacked arrays.
See Also
--------
stack : Join a sequence of arrays along a new axis.
concatenate : Join a sequence of arrays along an existing axis.
block : Assemble an nd-array from nested lists of blocks.
split : Split array into a list of multiple sub-arrays of equal size.
Notes
-----
``unstack`` serves as the reverse operation of :py:func:`stack`, i.e.,
``stack(unstack(x, axis=axis), axis=axis) == x``.
This function is equivalent to ``tuple(np.moveaxis(x, axis, 0))``, since
iterating on an array iterates along the first axis.
Examples
--------
>>> arr = np.arange(24).reshape((2, 3, 4))
>>> np.unstack(arr)
(array([[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11]]),
array([[12, 13, 14, 15],
[16, 17, 18, 19],
[20, 21, 22, 23]]))
>>> np.unstack(arr, axis=1)
(array([[ 0, 1, 2, 3],
[12, 13, 14, 15]]),
array([[ 4, 5, 6, 7],
[16, 17, 18, 19]]),
array([[ 8, 9, 10, 11],
[20, 21, 22, 23]]))
>>> arr2 = np.stack(np.unstack(arr, axis=1), axis=1)
>>> arr2.shape
(2, 3, 4)
>>> np.all(arr == arr2)
np.True_
Vous êtes un professionnel et vous avez besoin d'une formation ?
RAG (Retrieval-Augmented Generation)et Fine Tuning d'un LLM
Voir le programme détaillé
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 :