Python theano.tensor 模块,mod() 实例源码

我们从Python开源项目中,提取了以下23个代码示例,用于说明如何使用theano.tensor.mod()

项目:Theano-Deep-learning    作者:GeekLiB    | 项目源码 | 文件源码
def test_mod_compile():
    """
    This test generate an Elemwise of Composite as:
        Elemwise{
            Composite{
                Composite{
                    Composite{
                        Composite{mod,EQ},
                        Switch},
                    mul},
                add}}

    The c_code generated is not compiling as of 30 June 2010. I fix the
    compilation in the same commit.
    """

    x = tensor.vector()
    y = tensor.vector()
    shape = x.shape
    out = tensor.switch(tensor.eq(3 % x.shape[0], 0), y, y[:-1])

    f = theano.function([x, y], out)
项目:crikey    作者:kastnerkyle    | 项目源码 | 文件源码
def diagonal_phase_gmm(true, mu, sigma, coeff, epsilon=1E-5):
    n_dim = true.ndim
    shape_t = true.shape
    true = true.reshape((-1, shape_t[-1]))
    true = true.dimshuffle(0, 1, 'x')
    inner0 = np.pi - abs(tensor.mod(true - mu, 2 * np.pi) - np.pi)
    inner = tensor.log(2 * np.pi) + 2 * tensor.log(sigma)
    inner += tensor.sqr(inner0 / sigma)
    inner = -0.5 * tensor.sum(inner, axis=1)
    nll = -logsumexp(tensor.log(coeff) + inner, axis=1)
    nll = nll.reshape(shape_t[:-1], ndim=n_dim-1)
    return nll
项目:crikey    作者:kastnerkyle    | 项目源码 | 文件源码
def single_dimensional_phase_gmms(true, mu, sigma, coeff, epsilon=1E-5):
    shape_t = true.shape
    true = true.reshape((-1, shape_t[-1]))
    true = true.dimshuffle(0, 1, 'x')
    inner0 = np.pi - abs(tensor.mod(true - mu, 2 * np.pi) - np.pi)
    inner = tensor.log(2 * np.pi) + 2 * tensor.log(sigma)
    inner += tensor.sqr(inner0 / sigma)
    inner = -0.5 * inner
    nll = -logsumexp(tensor.sum(tensor.log(coeff) + inner, axis=1), axis=1)
    nll = nll.reshape((shape_t[0], shape_t[1]))
    return nll
项目:crikey    作者:kastnerkyle    | 项目源码 | 文件源码
def diagonal_phase_gmm(true, mu, sigma, coeff, epsilon=1E-5):
    n_dim = true.ndim
    shape_t = true.shape
    true = true.reshape((-1, shape_t[-1]))
    true = true.dimshuffle(0, 1, 'x')
    inner0 = np.pi - abs(tensor.mod(true - mu, 2 * np.pi) - np.pi)
    inner = tensor.log(2 * np.pi) + 2 * tensor.log(sigma)
    inner += tensor.sqr(inner0 / sigma)
    inner = -0.5 * tensor.sum(inner, axis=1)
    nll = -logsumexp(tensor.log(coeff) + inner, axis=1)
    nll = nll.reshape(shape_t[:-1], ndim=n_dim-1)
    return nll
项目:crikey    作者:kastnerkyle    | 项目源码 | 文件源码
def single_dimensional_phase_gmms(true, mu, sigma, coeff, epsilon=1E-5):
    shape_t = true.shape
    true = true.reshape((-1, shape_t[-1]))
    true = true.dimshuffle(0, 1, 'x')
    inner0 = np.pi - abs(tensor.mod(true - mu, 2 * np.pi) - np.pi)
    inner = tensor.log(2 * np.pi) + 2 * tensor.log(sigma)
    inner += tensor.sqr(inner0 / sigma)
    inner = -0.5 * inner
    nll = -logsumexp(tensor.sum(tensor.log(coeff) + inner, axis=1), axis=1)
    nll = nll.reshape((shape_t[0], shape_t[1]))
    return nll
项目:crikey    作者:kastnerkyle    | 项目源码 | 文件源码
def diagonal_phase_gmm(true, mu, sigma, coeff, epsilon=1E-5):
    n_dim = true.ndim
    shape_t = true.shape
    true = true.reshape((-1, shape_t[-1]))
    true = true.dimshuffle(0, 1, 'x')
    inner0 = np.pi - abs(tensor.mod(true - mu, 2 * np.pi) - np.pi)
    inner = tensor.log(2 * np.pi) + 2 * tensor.log(sigma)
    inner += tensor.sqr(inner0 / sigma)
    inner = -0.5 * tensor.sum(inner, axis=1)
    nll = -logsumexp(tensor.log(coeff) + inner, axis=1)
    nll = nll.reshape(shape_t[:-1], ndim=n_dim-1)
    return nll
项目:crikey    作者:kastnerkyle    | 项目源码 | 文件源码
def diagonal_phase_gmm(true, mu, sigma, coeff, epsilon=1E-5):
    n_dim = true.ndim
    shape_t = true.shape
    true = true.reshape((-1, shape_t[-1]))
    true = true.dimshuffle(0, 1, 'x')
    inner0 = np.pi - abs(tensor.mod(true - mu, 2 * np.pi) - np.pi)
    inner = tensor.log(2 * np.pi) + 2 * tensor.log(sigma)
    inner += tensor.sqr(inner0 / sigma)
    inner = -0.5 * tensor.sum(inner, axis=1)
    nll = -logsumexp(tensor.log(coeff) + inner, axis=1)
    nll = nll.reshape(shape_t[:-1], ndim=n_dim-1)
    return nll
项目:crikey    作者:kastnerkyle    | 项目源码 | 文件源码
def single_dimensional_phase_gmms(true, mu, sigma, coeff, epsilon=1E-5):
    shape_t = true.shape
    true = true.reshape((-1, shape_t[-1]))
    true = true.dimshuffle(0, 1, 'x')
    inner0 = np.pi - abs(tensor.mod(true - mu, 2 * np.pi) - np.pi)
    inner = tensor.log(2 * np.pi) + 2 * tensor.log(sigma)
    inner += tensor.sqr(inner0 / sigma)
    inner = -0.5 * inner
    nll = -logsumexp(tensor.sum(tensor.log(coeff) + inner, axis=1), axis=1)
    nll = nll.reshape((shape_t[0], shape_t[1]))
    return nll
项目:crikey    作者:kastnerkyle    | 项目源码 | 文件源码
def diagonal_phase_gmm(true, mu, sigma, coeff, epsilon=1E-5):
    n_dim = true.ndim
    shape_t = true.shape
    true = true.reshape((-1, shape_t[-1]))
    true = true.dimshuffle(0, 1, 'x')
    inner0 = np.pi - abs(tensor.mod(true - mu, 2 * np.pi) - np.pi)
    inner = tensor.log(2 * np.pi) + 2 * tensor.log(sigma)
    inner += tensor.sqr(inner0 / sigma)
    inner = -0.5 * tensor.sum(inner, axis=1)
    nll = -logsumexp(tensor.log(coeff) + inner, axis=1)
    nll = nll.reshape(shape_t[:-1], ndim=n_dim-1)
    return nll
项目:crikey    作者:kastnerkyle    | 项目源码 | 文件源码
def single_dimensional_phase_gmms(true, mu, sigma, coeff, epsilon=1E-5):
    shape_t = true.shape
    true = true.reshape((-1, shape_t[-1]))
    true = true.dimshuffle(0, 1, 'x')
    inner0 = np.pi - abs(tensor.mod(true - mu, 2 * np.pi) - np.pi)
    inner = tensor.log(2 * np.pi) + 2 * tensor.log(sigma)
    inner += tensor.sqr(inner0 / sigma)
    inner = -0.5 * inner
    nll = -logsumexp(tensor.sum(tensor.log(coeff) + inner, axis=1), axis=1)
    nll = nll.reshape((shape_t[0], shape_t[1]))
    return nll
项目:crikey    作者:kastnerkyle    | 项目源码 | 文件源码
def diagonal_phase_gmm(true, mu, sigma, coeff, epsilon=1E-5):
    n_dim = true.ndim
    shape_t = true.shape
    true = true.reshape((-1, shape_t[-1]))
    true = true.dimshuffle(0, 1, 'x')
    inner0 = np.pi - abs(tensor.mod(true - mu, 2 * np.pi) - np.pi)
    inner = tensor.log(2 * np.pi) + 2 * tensor.log(sigma)
    inner += tensor.sqr(inner0 / sigma)
    inner = -0.5 * tensor.sum(inner, axis=1)
    nll = -logsumexp(tensor.log(coeff) + inner, axis=1)
    nll = nll.reshape(shape_t[:-1], ndim=n_dim-1)
    return nll
项目:crikey    作者:kastnerkyle    | 项目源码 | 文件源码
def diagonal_phase_gmm(true, mu, sigma, coeff, epsilon=1E-5):
    n_dim = true.ndim
    shape_t = true.shape
    true = true.reshape((-1, shape_t[-1]))
    true = true.dimshuffle(0, 1, 'x')
    inner0 = np.pi - abs(tensor.mod(true - mu, 2 * np.pi) - np.pi)
    inner = tensor.log(2 * np.pi) + 2 * tensor.log(sigma)
    inner += tensor.sqr(inner0 / sigma)
    inner = -0.5 * tensor.sum(inner, axis=1)
    nll = -logsumexp(tensor.log(coeff) + inner, axis=1)
    nll = nll.reshape(shape_t[:-1], ndim=n_dim-1)
    return nll
项目:crikey    作者:kastnerkyle    | 项目源码 | 文件源码
def single_dimensional_phase_gmms(true, mu, sigma, coeff, epsilon=1E-5):
    shape_t = true.shape
    true = true.reshape((-1, shape_t[-1]))
    true = true.dimshuffle(0, 1, 'x')
    inner0 = np.pi - abs(tensor.mod(true - mu, 2 * np.pi) - np.pi)
    inner = tensor.log(2 * np.pi) + 2 * tensor.log(sigma)
    inner += tensor.sqr(inner0 / sigma)
    inner = -0.5 * inner
    nll = -logsumexp(tensor.sum(tensor.log(coeff) + inner, axis=1), axis=1)
    nll = nll.reshape((shape_t[0], shape_t[1]))
    return nll
项目:crikey    作者:kastnerkyle    | 项目源码 | 文件源码
def diagonal_phase_gmm(true, mu, sigma, coeff, epsilon=1E-5):
    n_dim = true.ndim
    shape_t = true.shape
    true = true.reshape((-1, shape_t[-1]))
    true = true.dimshuffle(0, 1, 'x')
    inner0 = np.pi - abs(tensor.mod(true - mu, 2 * np.pi) - np.pi)
    inner = tensor.log(2 * np.pi) + 2 * tensor.log(sigma)
    inner += tensor.sqr(inner0 / sigma)
    inner = -0.5 * tensor.sum(inner, axis=1)
    nll = -logsumexp(tensor.log(coeff) + inner, axis=1)
    nll = nll.reshape(shape_t[:-1], ndim=n_dim-1)
    return nll
项目:crikey    作者:kastnerkyle    | 项目源码 | 文件源码
def single_dimensional_phase_gmms(true, mu, sigma, coeff, epsilon=1E-5):
    shape_t = true.shape
    true = true.reshape((-1, shape_t[-1]))
    true = true.dimshuffle(0, 1, 'x')
    inner0 = np.pi - abs(tensor.mod(true - mu, 2 * np.pi) - np.pi)
    inner = tensor.log(2 * np.pi) + 2 * tensor.log(sigma)
    inner += tensor.sqr(inner0 / sigma)
    inner = -0.5 * inner
    nll = -logsumexp(tensor.sum(tensor.log(coeff) + inner, axis=1), axis=1)
    nll = nll.reshape((shape_t[0], shape_t[1]))
    return nll
项目:crikey    作者:kastnerkyle    | 项目源码 | 文件源码
def diagonal_phase_gmm(true, mu, sigma, coeff, epsilon=1E-5):
    n_dim = true.ndim
    shape_t = true.shape
    true = true.reshape((-1, shape_t[-1]))
    true = true.dimshuffle(0, 1, 'x')
    inner0 = np.pi - abs(tensor.mod(true - mu, 2 * np.pi) - np.pi)
    inner = tensor.log(2 * np.pi) + 2 * tensor.log(sigma)
    inner += tensor.sqr(inner0 / sigma)
    inner = -0.5 * tensor.sum(inner, axis=1)
    nll = -logsumexp(tensor.log(coeff) + inner, axis=1)
    nll = nll.reshape(shape_t[:-1], ndim=n_dim-1)
    return nll
项目:crikey    作者:kastnerkyle    | 项目源码 | 文件源码
def diagonal_phase_gmm(true, mu, sigma, coeff, epsilon=1E-5):
    n_dim = true.ndim
    shape_t = true.shape
    true = true.reshape((-1, shape_t[-1]))
    true = true.dimshuffle(0, 1, 'x')
    inner0 = np.pi - abs(tensor.mod(true - mu, 2 * np.pi) - np.pi)
    inner = tensor.log(2 * np.pi) + 2 * tensor.log(sigma)
    inner += tensor.sqr(inner0 / sigma)
    inner = -0.5 * tensor.sum(inner, axis=1)
    nll = -logsumexp(tensor.log(coeff) + inner, axis=1)
    nll = nll.reshape(shape_t[:-1], ndim=n_dim-1)
    return nll
项目:crikey    作者:kastnerkyle    | 项目源码 | 文件源码
def single_dimensional_phase_gmms(true, mu, sigma, coeff, epsilon=1E-5):
    shape_t = true.shape
    true = true.reshape((-1, shape_t[-1]))
    true = true.dimshuffle(0, 1, 'x')
    inner0 = np.pi - abs(tensor.mod(true - mu, 2 * np.pi) - np.pi)
    inner = tensor.log(2 * np.pi) + 2 * tensor.log(sigma)
    inner += tensor.sqr(inner0 / sigma)
    inner = -0.5 * inner
    nll = -logsumexp(tensor.sum(tensor.log(coeff) + inner, axis=1), axis=1)
    nll = nll.reshape((shape_t[0], shape_t[1]))
    return nll
项目:crikey    作者:kastnerkyle    | 项目源码 | 文件源码
def diagonal_phase_gmm(true, mu, sigma, coeff, epsilon=1E-5):
    n_dim = true.ndim
    shape_t = true.shape
    true = true.reshape((-1, shape_t[-1]))
    true = true.dimshuffle(0, 1, 'x')
    inner0 = np.pi - abs(tensor.mod(true - mu, 2 * np.pi) - np.pi)
    inner = tensor.log(2 * np.pi) + 2 * tensor.log(sigma)
    inner += tensor.sqr(inner0 / sigma)
    inner = -0.5 * tensor.sum(inner, axis=1)
    nll = -logsumexp(tensor.log(coeff) + inner, axis=1)
    nll = nll.reshape(shape_t[:-1], ndim=n_dim-1)
    return nll
项目:crikey    作者:kastnerkyle    | 项目源码 | 文件源码
def single_dimensional_phase_gmms(true, mu, sigma, coeff, epsilon=1E-5):
    shape_t = true.shape
    true = true.reshape((-1, shape_t[-1]))
    true = true.dimshuffle(0, 1, 'x')
    inner0 = np.pi - abs(tensor.mod(true - mu, 2 * np.pi) - np.pi)
    inner = tensor.log(2 * np.pi) + 2 * tensor.log(sigma)
    inner += tensor.sqr(inner0 / sigma)
    inner = -0.5 * inner
    nll = -logsumexp(tensor.sum(tensor.log(coeff) + inner, axis=1), axis=1)
    nll = nll.reshape((shape_t[0], shape_t[1]))
    return nll
项目:crikey    作者:kastnerkyle    | 项目源码 | 文件源码
def diagonal_phase_gmm(true, mu, sigma, coeff, epsilon=1E-5):
    n_dim = true.ndim
    shape_t = true.shape
    true = true.reshape((-1, shape_t[-1]))
    true = true.dimshuffle(0, 1, 'x')
    inner0 = np.pi - abs(tensor.mod(true - mu, 2 * np.pi) - np.pi)
    inner = tensor.log(2 * np.pi) + 2 * tensor.log(sigma)
    inner += tensor.sqr(inner0 / sigma)
    inner = -0.5 * tensor.sum(inner, axis=1)
    nll = -logsumexp(tensor.log(coeff) + inner, axis=1)
    nll = nll.reshape(shape_t[:-1], ndim=n_dim-1)
    return nll
项目:crikey    作者:kastnerkyle    | 项目源码 | 文件源码
def diagonal_phase_gmm(true, mu, sigma, coeff, epsilon=1E-5):
    n_dim = true.ndim
    shape_t = true.shape
    true = true.reshape((-1, shape_t[-1]))
    true = true.dimshuffle(0, 1, 'x')
    inner0 = np.pi - abs(tensor.mod(true - mu, 2 * np.pi) - np.pi)
    inner = tensor.log(2 * np.pi) + 2 * tensor.log(sigma)
    inner += tensor.sqr(inner0 / sigma)
    inner = -0.5 * tensor.sum(inner, axis=1)
    nll = -logsumexp(tensor.log(coeff) + inner, axis=1)
    nll = nll.reshape(shape_t[:-1], ndim=n_dim-1)
    return nll
项目:crikey    作者:kastnerkyle    | 项目源码 | 文件源码
def single_dimensional_phase_gmms(true, mu, sigma, coeff, epsilon=1E-5):
    shape_t = true.shape
    true = true.reshape((-1, shape_t[-1]))
    true = true.dimshuffle(0, 1, 'x')
    inner0 = np.pi - abs(tensor.mod(true - mu, 2 * np.pi) - np.pi)
    inner = tensor.log(2 * np.pi) + 2 * tensor.log(sigma)
    inner += tensor.sqr(inner0 / sigma)
    inner = -0.5 * inner
    nll = -logsumexp(tensor.sum(tensor.log(coeff) + inner, axis=1), axis=1)
    nll = nll.reshape((shape_t[0], shape_t[1]))
    return nll