当前位置: 首页>>代码示例>>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;未经允许,请勿转载。