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


Python numpy.float_power方法代碼示例

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


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

示例1: _draw_samples

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import float_power [as 別名]
def _draw_samples(self, size, random_state):
        seed = random_state.randint(0, 10**6, 1)[0]
        samples = self.other_param.draw_samples(size, random_state=ia.new_random_state(seed))

        elementwise = self.elementwise and not isinstance(self.val, Deterministic)

        if elementwise:
            exponents = self.val.draw_samples(size, random_state=ia.new_random_state(seed+1))
        else:
            exponents = self.val.draw_sample(random_state=ia.new_random_state(seed+1))

        # without this we get int results in the case of
        # Power(<int>, <stochastic float param>)
        samples, exponents = both_np_float_if_one_is_float(samples, exponents)
        samples_dtype = samples.dtype

        # float_power requires numpy>=1.12
        #result = np.float_power(samples, exponents)
        # TODO why was float32 type here replaced with complex number
        # formulation?
        result = np.power(samples.astype(np.complex), exponents).real
        if result.dtype != samples_dtype:
            result = result.astype(samples_dtype)

        return result 
開發者ID:JoshuaPiinRueyPan,項目名稱:ViolenceDetection,代碼行數:27,代碼來源:parameters.py

示例2: estimate

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import float_power [as 別名]
def estimate(self, query, logged_ranking, new_ranking, logged_value):
        exactMatch=numpy.absolute(new_ranking-logged_ranking).sum() == 0
        currentValue=0.0
        if exactMatch:
            numAllowedDocs=self.loggingPolicy.dataset.docsPerQuery[query]
            validDocs=logged_ranking.size
            invPropensity=None
            if self.loggingPolicy.allowRepetitions:
                invPropensity=numpy.float_power(numAllowedDocs, validDocs)
            else:
                invPropensity=numpy.prod(range(numAllowedDocs+1-validDocs, numAllowedDocs+1), dtype=numpy.float64)
                
            currentValue=logged_value*invPropensity

        self.updateRunningAverage(currentValue)
        return self.runningMean 
開發者ID:adith387,項目名稱:slates_semisynth_expts,代碼行數:18,代碼來源:Estimators.py

示例3: pick_move

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import float_power [as 別名]
def pick_move(self, game, side):
        possible_moves = game.possible_moves(side)
        if len(possible_moves) == 0:
            possible_moves.append((-1,-1))
        monte_prob = self.monte_carlo(game, side)
        
        if self.train:
            self.temp_state.append((self.preprocess_input(game.board, side), np.divide(monte_prob, np.sum(monte_prob))))
        
        monte_prob = np.float_power(monte_prob, 1/self.tau)
        monte_prob = np.divide(monte_prob, np.sum(monte_prob))
        
        r = random()
        for i, move in enumerate(possible_moves):
            r -= monte_prob[Othello.move_id(move)]
            if r <= 0:
                return move
        return possible_moves[-1] 
開發者ID:bhansconnect,項目名稱:alpha_zero_othello,代碼行數:20,代碼來源:aiplayer.py

示例4: plot_saliency

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import float_power [as 別名]
def plot_saliency(raw_img, image_var, img_embedding_var, caption_var):
    dis = (caption_var.squeeze() * img_embedding_var.squeeze()).sum()
    dis.backward(retain_graph=True)

    grad = image_var.grad.data.cpu().squeeze().numpy().transpose((1, 2, 0))
    grad = normalize_grad(grad, stat=True)
    grad = imresize((grad * 255).astype('uint8'), (raw_img.height, raw_img.width)) / 255
    grad = normalize_grad(grad.mean(axis=-1, keepdims=True).repeat(3, axis=-1))
    grad = np.float_power(grad, args.grad_power)

    np_img = np.array(raw_img)
    masked_img = np_img * grad
    final = np.hstack([np_img, masked_img.astype('uint8'), (grad * 255).astype('uint8')])
    return Image.fromarray(final.astype('uint8')) 
開發者ID:ExplorerFreda,項目名稱:VSE-C,代碼行數:16,代碼來源:saliency_visualization.py

示例5: _fractal_dfa_fluctuation

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import float_power [as 別名]
def _fractal_dfa_fluctuation(segments, trends, multifractal=False, q=2):

    detrended = segments - trends

    if multifractal is True:
        var = np.var(detrended, axis=1)
        fluctuation = np.float_power(np.mean(np.float_power(var, q / 2), axis=1) / 2, 1 / q.T)
        fluctuation = np.mean(fluctuation)  # Average over qs (not sure of that!)

    else:
        # Compute Root Mean Square (RMS)
        fluctuation = np.sum(detrended ** 2, axis=1) / detrended.shape[1]
        fluctuation = np.sqrt(np.sum(fluctuation) / len(fluctuation))

    return fluctuation 
開發者ID:neuropsychology,項目名稱:NeuroKit,代碼行數:17,代碼來源:fractal_dfa.py

示例6: _fractal_mfdfa_q

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import float_power [as 別名]
def _fractal_mfdfa_q(q=2):
    # TODO: Add log calculator for q ≈ 0

    # Fractal powers as floats
    q = np.asarray_chkfinite(q, dtype=np.float)

    # Ensure q≈0 is removed, since it does not converge. Limit set at |q| < 0.1
    q = q[(q < -0.1) + (q > 0.1)]

    # Reshape q to perform np.float_power
    q = q.reshape(-1, 1)
    return q 
開發者ID:neuropsychology,項目名稱:NeuroKit,代碼行數:14,代碼來源:fractal_dfa.py

示例7: test_type_conversion

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import float_power [as 別名]
def test_type_conversion(self):
        arg_type = '?bhilBHILefdgFDG'
        res_type = 'ddddddddddddgDDG'
        for dtin, dtout in zip(arg_type, res_type):
            msg = "dtin: %s, dtout: %s" % (dtin, dtout)
            arg = np.ones(1, dtype=dtin)
            res = np.float_power(arg, arg)
            assert_(res.dtype.name == np.dtype(dtout).name, msg) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:10,代碼來源:test_umath.py

示例8: _argcheck

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import float_power [as 別名]
def _argcheck(self, h, k):
        condlist = [np.logical_and(h > 0, k > 0),
                    np.logical_and(h > 0, k == 0),
                    np.logical_and(h > 0, k < 0),
                    np.logical_and(h <= 0, k > 0),
                    np.logical_and(h <= 0, k == 0),
                    np.logical_and(h <= 0, k < 0)]

        def f0(h, k):
            return (1.0 - float_power(h, -k))/k

        def f1(h, k):
            return np.log(h)

        def f3(h, k):
            a = np.empty(np.shape(h))
            a[:] = -np.inf
            return a

        def f5(h, k):
            return 1.0/k

        self.a = _lazyselect(condlist,
                             [f0, f1, f0, f3, f3, f5],
                             [h, k],
                             default=np.nan)

        def f0(h, k):
            return 1.0/k

        def f1(h, k):
            a = np.empty(np.shape(h))
            a[:] = np.inf
            return a

        self.b = _lazyselect(condlist,
                             [f0, f1, f1, f0, f1, f1],
                             [h, k],
                             default=np.nan)
        return h == h 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:42,代碼來源:_continuous_distns.py

示例9: float_power

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import float_power [as 別名]
def float_power(x1, x2):
  return power(x1, x2) 
開發者ID:google,項目名稱:trax,代碼行數:4,代碼來源:math_ops.py

示例10: _draw_samples

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import float_power [as 別名]
def _draw_samples(self, size, random_state):
        rngs = random_state.duplicate(2)
        samples = self.other_param.draw_samples(size, random_state=rngs[0])

        elementwise = (
            self.elementwise
            and not isinstance(self.val, Deterministic))

        if elementwise:
            exponents = self.val.draw_samples(size, random_state=rngs[1])
        else:
            exponents = self.val.draw_sample(random_state=rngs[1])

        # without this we get int results in the case of
        # Power(<int>, <stochastic float param>)
        samples, exponents = both_np_float_if_one_is_float(samples, exponents)
        samples_dtype = samples.dtype

        # TODO switch to this as numpy>=1.15 is now a requirement
        #      float_power requires numpy>=1.12
        # result = np.float_power(samples, exponents)
        # TODO why was float32 type here replaced with complex number
        #      formulation?
        result = np.power(samples.astype(np.complex), exponents).real
        if result.dtype != samples_dtype:
            result = result.astype(samples_dtype)

        return result 
開發者ID:aleju,項目名稱:imgaug,代碼行數:30,代碼來源:parameters.py

示例11: _draw_samples

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import float_power [as 別名]
def _draw_samples(self, size, random_state):
        seed = random_state.randint(0, 10**6, 1)[0]
        samples = self.other_param.draw_samples(
            size,
            random_state=eu.new_random_state(seed))

        elementwise = self.elementwise and not isinstance(self.val, Deterministic)

        if elementwise:
            exponents = self.val.draw_samples(
                size,
                random_state=eu.new_random_state(seed+1))
        else:
            exponents = self.val.draw_sample(
                random_state=eu.new_random_state(seed+1))

        # without this we get int results in the case of
        # Power(<int>, <stochastic float param>)
        samples, exponents = both_np_float_if_one_is_float(samples, exponents)
        samples_dtype = samples.dtype

        # float_power requires numpy>=1.12
        #result = np.float_power(samples, exponents)
        # TODO why was float32 type here replaced with complex number
        # formulation?
        result = np.power(samples.astype(np.complex), exponents).real
        if result.dtype != samples_dtype:
            result = result.astype(samples_dtype)

        return result 
開發者ID:liuguiyangnwpu,項目名稱:DL.EyeSight,代碼行數:32,代碼來源:parameter.py


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