Exemplo n.º 1
0
def normal_like(x, mean=0.0, scale=1.0, seed=auto_select, name=''):
    """normal_like(x, mean=0.0, scale=1.0, seed=auto_select, name='')
    Generates samples from the normal distribution with mean `mean` and standard deviation `scale`.

    Args:
        x: cntk variable (input, output, parameter, or constant) from which to copy the shape, data type, and dynamic axes.
        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:
        >>> x = C.parameter((2,3,4))
        >>> z = C.random.normal_like(x, 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, -0.011913, -0.236371],
                [-1.207685, -0.495846,  0.037022, -1.220596]],
        <BLANKLINE>
               [[ 0.872981,  0.654405, -0.111421, -0.544074],
                [ 1.543746, -0.63555 , -1.072869, -0.379701],
                [ 0.592069, -1.035192,  1.679303, -0.391963]]], dtype=float32)
    """
    from cntk.cntk_py import normal_random_like
    x = sanitize_input(x)
    return normal_random_like(x, mean, scale, seed, name)
Exemplo n.º 2
0
def normal_like(x, mean=0.0, scale=1.0, seed=auto_select, name=''):
    """normal_like(x, mean=0.0, scale=1.0, seed=auto_select, name='')
    Generates samples from the normal distribution with mean `mean` and standard deviation `scale`.

    Args:
        x: cntk variable (input, output, parameter, or constant) from which to copy the shape, data type, and dynamic axes.
        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:
        >>> x = C.parameter((2,3,4))
        >>> z = C.random.normal_like(x, 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, -0.011913, -0.236371],
                [-1.207685, -0.495846,  0.037022, -1.220596]],
        <BLANKLINE>
               [[ 0.872981,  0.654405, -0.111421, -0.544074],
                [ 1.543746, -0.63555 , -1.072869, -0.379701],
                [ 0.592069, -1.035192,  1.679303, -0.391963]]], dtype=float32)
    """
    from cntk.cntk_py import normal_random_like
    x = sanitize_input(x)
    return normal_random_like(x, mean, scale, seed, name)