コード例 #1
0
ファイル: __init__.py プロジェクト: OlegBoulanov/CNTK
def gumbel(shape, dtype=default_override_or(np.float32), loc=0.0, scale=1.0, seed=auto_select, name=''):
    """gumbel(shape, dtype=default_override_or(np.float32), loc=0.0, scale=1.0, seed=auto_select, name='')
    Generates samples from the Gumbel distribution with location `loc` and scale `scale`.

    Args:
        shape (tuple): shape of the output (entries are independent random draws)
        dtype (np.float32 or np.float64): data type. Default is np.float32.
        loc (float): location of the distribution
        scale (float): scale of the distribution
        seed (int): pseudo random number generator seed (default: automatically select a unique seed)
        name (str, optional): the name of the Function instance in the network

    Returns:
        :class:`~cntk.ops.functions.Function`

    Examples:
        >>> g = C.random.gumbel((2,3), seed=98052)
        >>> g.eval(device=C.cpu()) # explicitly setting cpu because this is tested on multiple platforms; leave it unspecified in your code
        array([[-0.987713, -0.522298,  0.425918],
               [-1.019599,  5.435177,  1.586071]], dtype=float32)

    See also:
        `The Gumbel-Max Trick
        <https://hips.seas.harvard.edu/blog/2013/04/06/the-gumbel-max-trick-for-discrete-distributions/>`_.
    """
    from cntk.cntk_py import gumbel_random
    shape, dtype = sanitize_random_args(shape, dtype)
    return gumbel_random(shape, dtype, loc, scale, seed, name)
コード例 #2
0
ファイル: __init__.py プロジェクト: OlegBoulanov/CNTK
def uniform(shape, dtype=default_override_or(np.float32), low=0.0, high=1.0, seed=auto_select, name=''):
    """uniform(shape, dtype=default_override_or(np.float32), low=0.0, high=1.0, seed=auto_select, name='')
    Generates samples from the uniform distribution in the interval [`low`,`high`).

    Args:
        shape (tuple): shape of the output (entries are independent random draws)
        dtype (np.float32 or np.float64): data type. Default is np.float32.
        low (float): lower end of the range of the random numbers
        high (float): upper end of the range of the random numbers
        seed (int): pseudo random number generator seed (default: automatically select a unique seed)
        name (str, optional): the name of the Function instance in the network

    Returns:
        :class:`~cntk.ops.functions.Function`

    Examples:
        >>> u = C.random.uniform((2,3), seed=98052)
        >>> u.eval(device=C.cpu()) # explicitly setting cpu because this is tested on multiple platforms; leave it unspecified in your code
        array([[ 0.931785,  0.814722,  0.479606],
               [ 0.937468,  0.004351,  0.185131]], dtype=float32)

    """
    from cntk.cntk_py import uniform_random
    shape, dtype = sanitize_random_args(shape, dtype)
    return uniform_random(shape, dtype, low, high, seed, name)
コード例 #3
0
def gumbel(shape,
           dtype=default_override_or(np.float32),
           loc=0.0,
           scale=1.0,
           seed=auto_select,
           name=''):
    """gumbel(shape, dtype=default_override_or(np.float32), loc=0.0, scale=1.0, seed=auto_select, name='')
    Generates samples from the Gumbel distribution with location `loc` and scale `scale`.

    Args:
        shape (tuple): shape of the output (entries are independent random draws)
        dtype (np.float32 or np.float64): data type. Default is np.float32.
        loc (float): location of the distribution
        scale (float): scale of the distribution
        seed (int): pseudo random number generator seed (default: automatically select a unique seed)
        name (str, optional): the name of the Function instance in the network

    Returns:
        :class:`~cntk.ops.functions.Function`

    Examples:
        >>> g = C.random.gumbel((2,3), seed=98052)
        >>> g.eval(device=C.cpu()) # explicitly setting cpu because this is tested on multiple platforms; leave it unspecified in your code
        array([[-0.987713, -0.522298,  0.425918],
               [-1.019599,  5.435177,  1.586071]], dtype=float32)

    See also:
        `The Gumbel-Max Trick
        <https://hips.seas.harvard.edu/blog/2013/04/06/the-gumbel-max-trick-for-discrete-distributions/>`_.
    """
    from cntk.cntk_py import gumbel_random
    shape, dtype = sanitize_random_args(shape, dtype)
    return gumbel_random(shape, dtype, loc, scale, seed, name)
コード例 #4
0
def normal(shape,
           dtype=default_override_or(np.float32),
           mean=0.0,
           scale=1.0,
           seed=auto_select,
           name=''):
    """normal(shape, dtype=default_override_or(np.float32), mean=0.0, scale=1.0, seed=auto_select, name='')
    Generates samples from the normal distribution with mean `mean` and standard deviation `scale`.

    Args:
        shape (tuple): shape of the output (entries are independent random draws)
        dtype (np.float32 or np.float64): data type. Default is np.float32.
        mean (float): mean of the distribution
        scale (float): scale (standard deviation) of the distribution
        seed (int): pseudo random number generator seed (default: automatically select a unique seed)
        name (str, optional): the name of the Function instance in the network

    Returns:
        :class:`~cntk.ops.functions.Function`

    Examples:
        >>> z = C.random.normal((2,3), seed=98052)
        >>> z.eval(device=C.cpu()) # explicitly setting cpu because this is tested on multiple platforms; leave it unspecified in your code
        array([[ 1.803254,  0.995395, -0.631974],
               [-1.73672 ,  0.005615, -0.340025]], dtype=float32)
    """
    from cntk.cntk_py import normal_random
    shape, dtype = sanitize_random_args(shape, dtype)
    return normal_random(shape, dtype, mean, scale, seed, name)
コード例 #5
0
def uniform(shape,
            dtype=default_override_or(np.float32),
            low=0.0,
            high=1.0,
            seed=auto_select,
            name=''):
    """uniform(shape, dtype=default_override_or(np.float32), low=0.0, high=1.0, seed=auto_select, name='')
    Generates samples from the uniform distribution in the interval [`low`,`high`).

    Args:
        shape (tuple): shape of the output (entries are independent random draws)
        dtype (np.float32 or np.float64): data type. Default is np.float32.
        low (float): lower end of the range of the random numbers
        high (float): upper end of the range of the random numbers
        seed (int): pseudo random number generator seed (default: automatically select a unique seed)
        name (str, optional): the name of the Function instance in the network

    Returns:
        :class:`~cntk.ops.functions.Function`

    Examples:
        >>> u = C.random.uniform((2,3), seed=98052)
        >>> u.eval(device=C.cpu()) # explicitly setting cpu because this is tested on multiple platforms; leave it unspecified in your code
        array([[ 0.931785,  0.814722,  0.479606],
               [ 0.937468,  0.004351,  0.185131]], dtype=float32)

    """
    from cntk.cntk_py import uniform_random
    shape, dtype = sanitize_random_args(shape, dtype)
    return uniform_random(shape, dtype, low, high, seed, name)
コード例 #6
0
def bernoulli(shape,
              dtype=default_override_or(np.float32),
              mean=0.5,
              seed=auto_select,
              name=''):
    """bernoulli(shape, dtype=default_override_or(np.float32), mean=0.5, seed=auto_select, name='')
    Generates samples from the Bernoulli distribution with success probability `mean`.

    Args:
        shape (tuple): shape of the output (entries are independent random draws)
        dtype (np.float32 or np.float64): data type. Default is np.float32.
        mean (float): success probability
        seed (int): pseudo random number generator seed (default: automatically select a unique seed)
        name (str, optional): the name of the Function instance in the network

    Returns:
        :class:`~cntk.ops.functions.Function`

    Examples:
        >>> b = C.random.bernoulli((2,3), seed=98052)
        >>> b.eval(device=C.cpu()) # explicitly setting cpu because this is tested on multiple platforms; leave it unspecified in your code
        array([[ 1.,  1.,  0.],
               [ 1.,  0.,  0.]], dtype=float32)
    """
    from cntk.cntk_py import bernoulli_random
    shape, dtype = sanitize_random_args(shape, dtype)
    return bernoulli_random(shape, dtype, mean, seed, name)
コード例 #7
0
ファイル: __init__.py プロジェクト: OlegBoulanov/CNTK
def bernoulli(shape, dtype=default_override_or(np.float32), mean=0.5, seed=auto_select, name=''):
    """bernoulli(shape, dtype=default_override_or(np.float32), mean=0.5, seed=auto_select, name='')
    Generates samples from the Bernoulli distribution with success probability `mean`.

    Args:
        shape (tuple): shape of the output (entries are independent random draws)
        dtype (np.float32 or np.float64): data type. Default is np.float32.
        mean (float): success probability
        seed (int): pseudo random number generator seed (default: automatically select a unique seed)
        name (str, optional): the name of the Function instance in the network

    Returns:
        :class:`~cntk.ops.functions.Function`

    Examples:
        >>> b = C.random.bernoulli((2,3), seed=98052)
        >>> b.eval(device=C.cpu()) # explicitly setting cpu because this is tested on multiple platforms; leave it unspecified in your code
        array([[ 1.,  1.,  0.],
               [ 1.,  0.,  0.]], dtype=float32)
    """
    from cntk.cntk_py import bernoulli_random
    shape, dtype = sanitize_random_args(shape, dtype)
    return bernoulli_random(shape, dtype, mean, seed, name)
コード例 #8
0
ファイル: __init__.py プロジェクト: OlegBoulanov/CNTK
def normal(shape, dtype=default_override_or(np.float32), mean=0.0, scale=1.0, seed=auto_select, name=''):
    """normal(shape, dtype=default_override_or(np.float32), mean=0.0, scale=1.0, seed=auto_select, name='')
    Generates samples from the normal distribution with mean `mean` and standard deviation `scale`.

    Args:
        shape (tuple): shape of the output (entries are independent random draws)
        dtype (np.float32 or np.float64): data type. Default is np.float32.
        mean (float): mean of the distribution
        scale (float): scale (standard deviation) of the distribution
        seed (int): pseudo random number generator seed (default: automatically select a unique seed)
        name (str, optional): the name of the Function instance in the network

    Returns:
        :class:`~cntk.ops.functions.Function`

    Examples:
        >>> z = C.random.normal((2,3), seed=98052)
        >>> z.eval(device=C.cpu()) # explicitly setting cpu because this is tested on multiple platforms; leave it unspecified in your code
        array([[ 1.803254,  0.995395, -0.631974],
               [-1.73672 ,  0.005615, -0.340025]], dtype=float32)
    """
    from cntk.cntk_py import normal_random
    shape, dtype = sanitize_random_args(shape, dtype)
    return normal_random(shape, dtype, mean, scale, seed, name)