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


Python numpy.NINF屬性代碼示例

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


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

示例1: test_is_inf

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import NINF [as 別名]
def test_is_inf(self):
    if legacy_opset_pre_ver(10):
      raise unittest.SkipTest("ONNX version {} doesn't support IsInf.".format(
          defs.onnx_opset_version()))
    input = np.array([-1.2, np.nan, np.inf, 2.8, np.NINF, np.inf],
                     dtype=np.float32)
    expected_output = {
        "node_def": np.isinf(input),
        "node_def_neg_false": np.isposinf(input),
        "node_def_pos_false": np.isneginf(input)
    }
    node_defs = {
        "node_def":
            helper.make_node("IsInf", ["X"], ["Y"]),
        "node_def_neg_false":
            helper.make_node("IsInf", ["X"], ["Y"], detect_negative=0),
        "node_def_pos_false":
            helper.make_node("IsInf", ["X"], ["Y"], detect_positive=0)
    }
    for key in node_defs:
      output = run_node(node_defs[key], [input])
      np.testing.assert_equal(output["Y"], expected_output[key]) 
開發者ID:onnx,項目名稱:onnx-tensorflow,代碼行數:24,代碼來源:test_node.py

示例2: test_is_inf

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import NINF [as 別名]
def test_is_inf(self):
    if legacy_opset_pre_ver(10):
      raise unittest.SkipTest("ONNX version {} doesn't support IsInf.".format(
          defs.onnx_opset_version()))
    inp = np.array([-1.2, np.nan, np.inf, 2.8, np.NINF, np.inf],
                   dtype=np.float32)
    expected_output = np.isinf(inp)
    node_def = helper.make_node("IsInf", ["X"], ["Y"])
    graph_def = helper.make_graph(
        [node_def],
        name="test_unknown_shape",
        inputs=[
            helper.make_tensor_value_info("X", TensorProto.FLOAT, [None]),
        ],
        outputs=[helper.make_tensor_value_info("Y", TensorProto.BOOL, [None])])
    tf_rep = onnx_graph_to_tensorflow_rep(graph_def)
    output = tf_rep.run({"X": inp})
    np.testing.assert_equal(output["Y"], expected_output) 
開發者ID:onnx,項目名稱:onnx-tensorflow,代碼行數:20,代碼來源:test_dynamic_shape.py

示例3: ComputeEnabledAABB

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import NINF [as 別名]
def ComputeEnabledAABB(kinbody):
    """
    Returns the AABB of the enabled links of a KinBody.

    @param kinbody: an OpenRAVE KinBody
    @returns: AABB of the enabled links of the KinBody
    """
    from numpy import NINF, PINF
    from openravepy import AABB

    min_corner = numpy.array([PINF] * 3)
    max_corner = numpy.array([NINF] * 3)

    for link in kinbody.GetLinks():
        if link.IsEnabled():
            link_aabb = link.ComputeAABB()
            center = link_aabb.pos()
            half_extents = link_aabb.extents()
            min_corner = numpy.minimum(center - half_extents, min_corner)
            max_corner = numpy.maximum(center + half_extents, max_corner)

    center = (min_corner + max_corner) / 2.
    half_extents = (max_corner - min_corner) / 2.
    return AABB(center, half_extents) 
開發者ID:personalrobotics,項目名稱:prpy,代碼行數:26,代碼來源:util.py

示例4: test_constants

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import NINF [as 別名]
def test_constants():
    assert chainerx.Inf is numpy.Inf
    assert chainerx.Infinity is numpy.Infinity
    assert chainerx.NAN is numpy.NAN
    assert chainerx.NINF is numpy.NINF
    assert chainerx.NZERO is numpy.NZERO
    assert chainerx.NaN is numpy.NaN
    assert chainerx.PINF is numpy.PINF
    assert chainerx.PZERO is numpy.PZERO
    assert chainerx.e is numpy.e
    assert chainerx.euler_gamma is numpy.euler_gamma
    assert chainerx.inf is numpy.inf
    assert chainerx.infty is numpy.infty
    assert chainerx.nan is numpy.nan
    assert chainerx.newaxis is numpy.newaxis
    assert chainerx.pi is numpy.pi 
開發者ID:chainer,項目名稱:chainer,代碼行數:18,代碼來源:test_constants.py

示例5: normalize

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import NINF [as 別名]
def normalize(v):
    if isinstance(v, numpy.bool_):
        return bool(v)
    elif isinstance(v, numpy.ndarray):
        return [normalize(item) for item in v]
    elif v == numpy.NaN:
        return "NaN"
    elif v == numpy.NINF:
        return "-Infinity"
    elif v == numpy.PINF:
        return "Infinity"
    elif isinstance(v, numpy.float):
        return float(v)
    elif isinstance(v, tuple):
        return list(v)
    else:
        return v 
開發者ID:wikimedia,項目名稱:revscoring,代碼行數:19,代碼來源:util.py

示例6: _create_corpus_embed

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import NINF [as 別名]
def _create_corpus_embed(self):
        """
            msg_embed: batch_size * max_n_days * max_n_msgs * msg_embed_size

            => corpus_embed: batch_size * max_n_days * corpus_embed_size
        """
        with tf.name_scope('corpus_embed'):
            with tf.variable_scope('u_t'):
                proj_u = self._linear(self.msg_embed, self.msg_embed_size, 'tanh', use_bias=False)
                w_u = tf.get_variable('w_u', shape=(self.msg_embed_size, 1), initializer=self.initializer)
            u = tf.reduce_mean(tf.tensordot(proj_u, w_u, axes=1), axis=-1)  # batch_size * max_n_days * max_n_msgs

            mask_msgs = tf.sequence_mask(self.n_msgs_ph, maxlen=self.max_n_msgs, dtype=tf.bool, name='mask_msgs')
            ninf = tf.fill(tf.shape(mask_msgs), np.NINF)
            masked_score = tf.where(mask_msgs, u, ninf)
            u = neural.softmax(masked_score)  # batch_size * max_n_days * max_n_msgs
            u = tf.where(tf.is_nan(u), tf.zeros_like(u), u)  # replace nan with 0.0

            u = tf.expand_dims(u, axis=-2)  # batch_size * max_n_days * 1 * max_n_msgs
            corpus_embed = tf.matmul(u, self.msg_embed)  # batch_size * max_n_days * 1 * msg_embed_size
            corpus_embed = tf.reduce_mean(corpus_embed, axis=-2)  # batch_size * max_n_days * msg_embed_size
            self.corpus_embed = tf.nn.dropout(corpus_embed, keep_prob=1-self.dropout_ce, name='corpus_embed') 
開發者ID:yumoxu,項目名稱:stocknet-code,代碼行數:24,代碼來源:Model.py

示例7: lr_predict

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import NINF [as 別名]
def lr_predict(self, BV, data, num_sub):
        BV = np.asarray(BV)
        data = np.asarray(data)

        fs = data.dot(BV)
        n = data.shape[0]
        n_class = int(fs.shape[1] / num_sub)
        pres = np.ones((n, n_class)) * np.NINF
        for j in range(num_sub):
            f = fs[:, j: fs.shape[1]: num_sub]
            assert (np.all(f.shape == pres.shape))
            pres = np.fmax(pres, f)
        labels = -np.ones((n, n_class - 1))
        for line in range(n_class - 1):
            gt = np.nonzero(pres[:, line] > pres[:, n_class - 1])[0]
            labels[gt, line] = 1
        return pres, labels 
開發者ID:NUAA-AL,項目名稱:ALiPy,代碼行數:19,代碼來源:multi_label.py

示例8: _get_proposal_function

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import NINF [as 別名]
def _get_proposal_function(self, model, space):

        # Define proposal function for multi-fidelity
        ei = ExpectedImprovement(model)

        def proposal_func(x):
            x_ = x[None, :]
            # Map to highest fidelity
            idx = np.ones((x_.shape[0], 1)) * self.high_fidelity

            x_ = np.insert(x_, self.target_fidelity_index, idx, axis=1)

            if space.check_points_in_domain(x_):
                val = np.log(np.clip(ei.evaluate(x_)[0], 0., np.PINF))
                if np.any(np.isnan(val)):
                    return np.array([np.NINF])
                else:
                    return val
            else:
                return np.array([np.NINF])

        return proposal_func 
開發者ID:amzn,項目名稱:emukit,代碼行數:24,代碼來源:continuous_fidelity_entropy_search.py

示例9: _get_proposal_function

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import NINF [as 別名]
def _get_proposal_function(self, model, space):

        # Define proposal function for multi-fidelity
        ei = ExpectedImprovement(model)

        def proposal_func(x):
            x_ = x[None, :]

            # Add information source parameter into array
            idx = np.ones((x_.shape[0], 1)) * self.target_information_source_index
            x_ = np.insert(x_, self.source_idx, idx, axis=1)

            if space.check_points_in_domain(x_):
                val = np.log(np.clip(ei.evaluate(x_)[0], 0., np.PINF))
                if np.any(np.isnan(val)):
                    return np.array([np.NINF])
                else:
                    return val
            else:
                return np.array([np.NINF])

        return proposal_func 
開發者ID:amzn,項目名稱:emukit,代碼行數:24,代碼來源:entropy_search.py

示例10: test_df_rolling_corr

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import NINF [as 別名]
def test_df_rolling_corr(self):
        all_data = [
            list(range(10)), [1., -1., 0., 0.1, -0.1],
            [1., np.inf, np.inf, -1., 0., np.inf, np.NINF, np.NINF],
            [np.nan, np.inf, np.inf, np.nan, np.nan, np.nan, np.NINF, np.NZERO]
        ]
        length = min(len(d) for d in all_data)
        data = {n: d[:length] for n, d in zip(string.ascii_uppercase, all_data)}
        df = pd.DataFrame(data)
        for d in all_data:
            other = pd.Series(d)
            self._test_rolling_corr(df, other)

        other_all_data = deepcopy(all_data) + [list(range(10))[::-1]]
        other_all_data[1] = [-1., 1., 0., -0.1, 0.1, 0.]
        other_length = min(len(d) for d in other_all_data)
        other_data = {n: d[:other_length] for n, d in zip(string.ascii_uppercase, other_all_data)}
        other = pd.DataFrame(other_data)

        self._test_rolling_corr(df, other) 
開發者ID:IntelPython,項目名稱:sdc,代碼行數:22,代碼來源:test_rolling.py

示例11: test_df_rolling_cov

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import NINF [as 別名]
def test_df_rolling_cov(self):
        all_data = [
            list(range(10)), [1., -1., 0., 0.1, -0.1],
            [1., np.inf, np.inf, -1., 0., np.inf, np.NINF, np.NINF],
            [np.nan, np.inf, np.inf, np.nan, np.nan, np.nan, np.NINF, np.NZERO]
        ]
        length = min(len(d) for d in all_data)
        data = {n: d[:length] for n, d in zip(string.ascii_uppercase, all_data)}
        df = pd.DataFrame(data)
        for d in all_data:
            other = pd.Series(d)
            self._test_rolling_cov(df, other)

        other_all_data = deepcopy(all_data) + [list(range(10))[::-1]]
        other_all_data[1] = [-1., 1., 0., -0.1, 0.1]
        other_length = min(len(d) for d in other_all_data)
        other_data = {n: d[:other_length] for n, d in zip(string.ascii_uppercase, other_all_data)}
        other = pd.DataFrame(other_data)

        self._test_rolling_cov(df, other) 
開發者ID:IntelPython,項目名稱:sdc,代碼行數:22,代碼來源:test_rolling.py

示例12: value_bounds

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import NINF [as 別名]
def value_bounds(self, point):
    """
    Returns the (lower_bound, upper_bound) tuple of a point implied by the reference set and the monotone relationship vector.
    Use it to improve and understand the reference set without triggering a MonotoneError.
    Returns np.inf as the second argument if there is no upper bound and np.NINF as the first argument if there is no lower bound.

    Required argument:
    point -- Point at which to assess upper and lower bounds.
    """
    padj = point/self.scale
    points_greater_than = filter(lambda x: np.allclose(x,padj) or self.__monotone_rel__(x,padj)==1, self.points.keys())
    points_less_than = filter(lambda x: np.allclose(x,padj) or self.__monotone_rel__(padj,x)==1, self.points.keys())
    gtbound = np.inf if self.maxval is None else self.maxval
    ltbound = np.NINF if self.minval is None else self.minval
    for p in points_greater_than:
      gtbound = min(self.points[p],gtbound)
    for p in points_less_than:
      ltbound = max(self.points[p],ltbound)
    return ltbound, gtbound 
開發者ID:aothman,項目名稱:hiscore,代碼行數:21,代碼來源:engine.py

示例13: _norm

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import NINF [as 別名]
def _norm():
    def _impl(inputs, input_types):
        data = inputs[0]
        dtype = input_types[0]
        axis = None
        keepdims = False
        if len(inputs) > 3:
            axis = list(_infer_shape(inputs[2]))
            keepdims = bool(inputs[3])

        order = inputs[1]
        if order == np.inf:
            return _op.reduce.max(_op.abs(data), axis=axis, keepdims=keepdims)
        elif order == np.NINF:
            return _op.reduce.min(_op.abs(data), axis=axis, keepdims=keepdims)
        else:
            reci_order = _expr.const(1.0 / order, dtype=dtype)
            order = _expr.const(order)
            return _op.power(_op.reduce.sum(_op.power(_op.abs(data), order),
                                            axis=axis,
                                            keepdims=keepdims),
                             reci_order)
    return _impl 
開發者ID:apache,項目名稱:incubator-tvm,代碼行數:25,代碼來源:pytorch.py

示例14: __init__

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import NINF [as 別名]
def __init__(self, word2index, index2word, argsDict, dataset,
                 data_generator, use_sourcelang=False, use_image=True):
        super(Callback, self).__init__()

        self.verbose = True
        self.filename = "weights.hdf5"
        self.save_best_only = True

        self.val_loss = []
        self.best_val_loss = np.inf

        self.val_metric = []
        self.best_val_metric = np.NINF

        self.word2index = word2index
        self.index2word = index2word
        self.args = argsDict

        # used to control early stopping on the validation data
        self.wait = 0
        self.patience = self.args.patience

        # needed by model.predict in generate_sentences
        self.use_sourcelang = use_sourcelang
        self.use_image = use_image

        # controversial assignment but it makes it much easier to
        # do early stopping based on metrics
        self.data_generator = data_generator

        # this results in two file handlers for dataset (here and
        # data_generator)
        if not dataset:
            logger.warn("No dataset given, using flickr8k")
            self.dataset = h5py.File("flickr8k/dataset.h5", "r")
        else:
            self.dataset = h5py.File("%s/dataset.h5" % dataset, "r")
        if self.args.source_vectors is not None:
            self.source_dataset = h5py.File("%s/dataset.h5" % self.args.source_vectors, "r") 
開發者ID:elliottd,項目名稱:GroundedTranslation,代碼行數:41,代碼來源:Callbacks.py

示例15: test_any_ninf

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import NINF [as 別名]
def test_any_ninf(self):
        # atan2(+-y, -infinity) returns +-pi for finite y > 0.
        assert_almost_equal(ncu.arctan2(1, np.NINF),  np.pi)
        assert_almost_equal(ncu.arctan2(-1, np.NINF), -np.pi) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:6,代碼來源:test_umath.py


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