コード例 #1
0
ファイル: sample.py プロジェクト: yuhc/ava-cupy
def randn(*size, **kwarg):
    """Returns an array of standard normal random values.

    Each element of the array is normally distributed with zero mean and unit
    variance. All elements are identically and independently distributed
    (i.i.d.).

    Args:
        size (ints): The shape of the array.
        dtype: Data type specifier. Only :class:`numpy.float32` and
            :class:`numpy.float64` types are allowed.
            The default is :class:`numpy.float64`.

    Returns:
        cupy.ndarray: An array of standard normal random values.

    .. seealso:: :meth:`numpy.random.randn
                 <numpy.random.mtrand.RandomState.randn>`

    .. admonition:: Example

       .. code-block:: python

          >>> cupy.random.randn(3, 2)
          array([[0.41193321, 1.59579542],   # random
                 [0.47904589, 0.18566376],   # random
                 [0.59748424, 2.32602829]])  # random

          >>> cupy.random.randn(3, 2, dtype=cupy.float32)
          array([[ 0.1373886 ,  2.403238  ],                  # random
                 [ 0.84020025,  1.5089266 ],                  # random
                 [-1.2268474 , -0.48219103]], dtype=float32)  # random

    """
    dtype = kwarg.pop('dtype', float)
    if kwarg:
        raise TypeError('randn() got unexpected keyword arguments %s' %
                        ', '.join(kwarg.keys()))
    return distributions.normal(size=size, dtype=dtype)
コード例 #2
0
ファイル: sample.py プロジェクト: BRETT71/chainer
def randn(*size, **kwarg):
    """Returns an array of standand normal random values.

    Each element of the array is normally distributed with zero mean and unit
    variance. All elements are identically and independently distributed
    (i.i.d.).

    Args:
        size (tuple of ints): The shape of the array.
        dtype: Data type specifier. Only float32 and float64 types are allowed.
            The default is float64.

    Returns:
        cupy.ndarray: An array of standanr normal random values.

    .. seealso:: :func:`numpy.random.randn`

    """
    dtype = kwarg.pop('dtype', float)
    if kwarg:
        raise TypeError('randn() got unexpected keyword arguments %s'
                        % ', '.join(kwarg.keys()))
    return distributions.normal(size=size, dtype=dtype)
コード例 #3
0
ファイル: sample.py プロジェクト: yanweifu/chainer
def randn(*size, **kwarg):
    """Returns an array of standand normal random values.

    Each element of the array is normally distributed with zero mean and unit
    variance. All elements are identically and independently distributed
    (i.i.d.).

    Args:
        size (tuple of ints): The shape of the array.
        dtype: Data type specifier. Only float32 and float64 types are allowed.
            The default is float64.

    Returns:
        cupy.ndarray: An array of standanr normal random values.

    .. seealso:: :func:`numpy.random.randn`

    """
    dtype = kwarg.pop('dtype', float)
    if kwarg:
        raise TypeError('randn() got unexpected keyward arguments %s' %
                        ', '.join(kwarg.keys()))
    return distributions.normal(size=size, dtype=dtype)