Ejemplo n.º 1
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)
Ejemplo n.º 2
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)