當前位置: 首頁>>代碼示例>>Python>>正文


Python tensor.erf方法代碼示例

本文整理匯總了Python中theano.tensor.erf方法的典型用法代碼示例。如果您正苦於以下問題:Python tensor.erf方法的具體用法?Python tensor.erf怎麽用?Python tensor.erf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在theano.tensor的用法示例。


在下文中一共展示了tensor.erf方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from theano import tensor [as 別名]
# 或者: from theano.tensor import erf [as 別名]
def __init__(self, x, mu, sigma, *args, **kwargs):
        super(Normal, self).__init__(*args, **kwargs)
        self._logp = bound(
            -(x - mu)**2 / (2 * sigma**2) + T.log(1 / T.sqrt(sigma**2 * 2*np.pi)),
            sigma > 0
        )
        self._cdf = 0.5 * (1 + T.erf((x - mu)/(sigma*T.sqrt(2))))
        self._add_expr('x', x)
        self._add_expr('mu', mu)
        self._add_expr('sigma', sigma) 
開發者ID:ibab,項目名稱:python-mle,代碼行數:12,代碼來源:__init__.py

示例2: n_cdf

# 需要導入模塊: from theano import tensor [as 別名]
# 或者: from theano.tensor import erf [as 別名]
def n_cdf(x):
    return 0.5 * (1.0 + T.erf(x / T.sqrt(2.0))) 
開發者ID:muhanzhang,項目名稱:D-VAE,代碼行數:4,代碼來源:sparse_gp_theano_internal.py

示例3: discretized_gaussian

# 需要導入模塊: from theano import tensor [as 別名]
# 或者: from theano.tensor import erf [as 別名]
def discretized_gaussian(mean, logvar, binsize, sample=None):
    scale = T.exp(.5*logvar)
    if sample is None:
        _y = G.rng_curand.normal(size=mean.shape)
        sample = mean + scale * _y #sample from the actual logistic
        sample = T.floor(sample/binsize)*binsize #discretize the sample
    _sample = (T.floor(sample/binsize)*binsize - mean)/scale
    def _erf(x):
        return T.erf(x/T.sqrt(2.))
    logp = T.log( _erf(_sample + binsize/scale) - _erf(_sample) + 1e-7) + T.log(.5)
    logp = logp.flatten(2).sum(axis=1)
    #raise Exception()
    entr = (.5 * (T.log(2 * math.pi) + 1 + logvar)).flatten(2).sum(axis=1)
    return RandomVariable(sample, logp, entr, mean=mean, logvar=logvar) 
開發者ID:openai,項目名稱:iaf,代碼行數:16,代碼來源:rand.py

示例4: __init__

# 需要導入模塊: from theano import tensor [as 別名]
# 或者: from theano.tensor import erf [as 別名]
def __init__(self, mu=0.0, sigma=1.0):
        """Constructor.

        Parameters
        ----------
        * `mu` [float]:
            The distribution mean.

        * `sigma` [float]:
            The distribution standard deviation.
        """
        super(Normal, self).__init__(mu=mu, sigma=sigma)

        # pdf
        self.pdf_ = (
            (1. / np.sqrt(2. * np.pi)) / self.sigma *
            T.exp(-(self.X - self.mu) ** 2 / (2. * self.sigma ** 2))).ravel()
        self._make(self.pdf_, "pdf")

        # -log pdf
        self.nll_ = bound(
            T.log(self.sigma) + T.log(np.sqrt(2. * np.pi)) +
            (self.X - self.mu) ** 2 / (2. * self.sigma ** 2),
            np.inf,
            self.sigma > 0.).ravel()
        self._make(self.nll_, "nll")

        # cdf
        self.cdf_ = 0.5 * (1. + T.erf((self.X - self.mu) /
                                      (self.sigma * np.sqrt(2.)))).ravel()
        self._make(self.cdf_, "cdf")

        # ppf
        self.ppf_ = (self.mu +
                     np.sqrt(2.) * self.sigma * T.erfinv(2. * self.p - 1.))
        self._make(self.ppf_, "ppf", args=[self.p]) 
開發者ID:diana-hep,項目名稱:carl,代碼行數:38,代碼來源:normal.py

示例5: gelu2

# 需要導入模塊: from theano import tensor [as 別名]
# 或者: from theano.tensor import erf [as 別名]
def gelu2(x):
    '''
        similar to silu
    '''
    return x*(tt.erf(x) + 1) 
開發者ID:mcgillmrl,項目名稱:kusanagi,代碼行數:7,代碼來源:nonlinearities.py

示例6: cdf

# 需要導入模塊: from theano import tensor [as 別名]
# 或者: from theano.tensor import erf [as 別名]
def cdf(sample, mu=0, sigma=1, eps=1e-6):
    div = T.sqrt(2) * sigma
    erf_arg = (sample - mu) / div
    return .5 * (1 + T.erf(erf_arg)) 
開發者ID:317070,項目名稱:kaggle-heart,代碼行數:6,代碼來源:nn_heart.py

示例7: get_output_for

# 需要導入模塊: from theano import tensor [as 別名]
# 或者: from theano.tensor import erf [as 別名]
def get_output_for(self, input, **kwargs):
        mu = input[0]
        sigma = input[1]
        w = input[2]
        if self.log:
            sigma = T.exp(sigma)

        x_range = T.arange(0, 600).dimshuffle('x', 0, 'x')
        mu = mu.dimshuffle(0, 'x', 1)
        sigma = sigma.dimshuffle(0, 'x', 1)
        x = (x_range - mu) / (sigma * T.sqrt(2.) + 1e-16)
        cdf = (T.erf(x) + 1.) / 2.  # (bs, 600, n_mix)
        cdf = T.sum(cdf * w.dimshuffle(0, 'x', 1), axis=-1)
        return cdf 
開發者ID:317070,項目名稱:kaggle-heart,代碼行數:16,代碼來源:nn_heart.py

示例8: get_output_for

# 需要導入模塊: from theano import tensor [as 別名]
# 或者: from theano.tensor import erf [as 別名]
def get_output_for(self, input, **kwargs):
        if input.ndim > 3:
            # input: (batch, time, axis, verti, horiz)
            # needs: (batch, time, pixels)
            input = input.flatten(ndim=3)

        eps=1e-7
        clipped_input = T.clip(input, eps, 1-eps)
        mu = T.sum(clipped_input, axis=2).dimshuffle(0,1,'x')

        sigma = T.sqrt(T.sum(clipped_input * (1-clipped_input), axis=2).dimshuffle(0,1,'x') + eps)
        x_axis = theano.shared(np.arange(0, 600, dtype='float32')).dimshuffle('x','x',0)
        x = (x_axis - mu) / sigma
        return (T.erf(x) + 1)/2 
開發者ID:317070,項目名稱:kaggle-heart,代碼行數:16,代碼來源:volume_estimation_layers.py

示例9: get_output_for

# 需要導入模塊: from theano import tensor [as 別名]
# 或者: from theano.tensor import erf [as 別名]
def get_output_for(self, input, **kwargs):
        eps = 1e-7
        x_axis = theano.shared(np.arange(0, 600, dtype='float32')).dimshuffle('x',0)
        # This needs to be clipped to avoid NaN's!
        sigma = T.exp(T.clip(input[:,1].dimshuffle(0,'x'), -10, 10))
        #theano_printer.print_me_this("sigma", sigma)
        x = (x_axis - input[:,0].dimshuffle(0,'x')) / (sigma * np.sqrt(2).astype('float32'))
        return (T.erf(x) + 1)/2 
開發者ID:317070,項目名稱:kaggle-heart,代碼行數:10,代碼來源:layers.py

示例10: theano_mu_sigma_erf

# 需要導入模塊: from theano import tensor [as 別名]
# 或者: from theano.tensor import erf [as 別名]
def theano_mu_sigma_erf(mu_erf, sigma_erf, eps=1e-7):
    x_axis = theano.shared(np.arange(0, 600, dtype='float32')).dimshuffle('x',0)
    if sigma_erf.ndim==0:
        sigma_erf = T.clip(sigma_erf.dimshuffle('x','x'), eps, 1)
    elif sigma_erf.ndim==1:
        sigma_erf = T.clip(sigma_erf.dimshuffle(0,'x'), eps, 1)
    x = (x_axis - mu_erf.dimshuffle(0,'x')) / (sigma_erf * np.sqrt(2).astype('float32'))
    return (T.erf(x) + 1)/2 
開發者ID:317070,項目名稱:kaggle-heart,代碼行數:10,代碼來源:utils.py

示例11: numpy_mu_sigma_erf

# 需要導入模塊: from theano import tensor [as 別名]
# 或者: from theano.tensor import erf [as 別名]
def numpy_mu_sigma_erf(mu_erf, sigma_erf, eps=1e-7):
    batch_size = mu_erf.shape[0]
    x_axis = np.tile(np.arange(0, 600, dtype='float32'), (batch_size, 1))
    mu_erf = np.tile(mu_erf[:,None], (1, 600))
    sigma_erf = np.tile(sigma_erf[:,None], (1, 600))
    sigma_erf += eps

    x = (x_axis - mu_erf) / (sigma_erf * np.sqrt(2))
    return (erf(x) + 1)/2 
開發者ID:317070,項目名稱:kaggle-heart,代碼行數:11,代碼來源:utils.py


注:本文中的theano.tensor.erf方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。