当前位置: 首页>>代码示例>>Python>>正文


Python numpy.logical_not方法代码示例

本文整理汇总了Python中numpy.logical_not方法的典型用法代码示例。如果您正苦于以下问题:Python numpy.logical_not方法的具体用法?Python numpy.logical_not怎么用?Python numpy.logical_not使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在numpy的用法示例。


在下文中一共展示了numpy.logical_not方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_subsample_all_examples

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import logical_not [as 别名]
def test_subsample_all_examples(self):
    numpy_labels = np.random.permutation(300)
    indicator = tf.constant(np.ones(300) == 1)
    numpy_labels = (numpy_labels - 200) > 0

    labels = tf.constant(numpy_labels)

    sampler = (balanced_positive_negative_sampler.
               BalancedPositiveNegativeSampler())
    is_sampled = sampler.subsample(indicator, 64, labels)
    with self.test_session() as sess:
      is_sampled = sess.run(is_sampled)
      self.assertTrue(sum(is_sampled) == 64)
      self.assertTrue(sum(np.logical_and(numpy_labels, is_sampled)) == 32)
      self.assertTrue(sum(np.logical_and(
          np.logical_not(numpy_labels), is_sampled)) == 32) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:18,代码来源:balanced_positive_negative_sampler_test.py

示例2: test_subsample_selection

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import logical_not [as 别名]
def test_subsample_selection(self):
    # Test random sampling when only some examples can be sampled:
    # 100 samples, 20 positives, 10 positives cannot be sampled
    numpy_labels = np.arange(100)
    numpy_indicator = numpy_labels < 90
    indicator = tf.constant(numpy_indicator)
    numpy_labels = (numpy_labels - 80) >= 0

    labels = tf.constant(numpy_labels)

    sampler = (balanced_positive_negative_sampler.
               BalancedPositiveNegativeSampler())
    is_sampled = sampler.subsample(indicator, 64, labels)
    with self.test_session() as sess:
      is_sampled = sess.run(is_sampled)
      self.assertTrue(sum(is_sampled) == 64)
      self.assertTrue(sum(np.logical_and(numpy_labels, is_sampled)) == 10)
      self.assertTrue(sum(np.logical_and(
          np.logical_not(numpy_labels), is_sampled)) == 54)
      self.assertAllEqual(is_sampled, np.logical_and(is_sampled,
                                                     numpy_indicator)) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:23,代码来源:balanced_positive_negative_sampler_test.py

示例3: _get_result_map

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import logical_not [as 别名]
def _get_result_map(self, mask):
        """Processing mask data"""

        # mask.shape[0]: row, mask.shape[1]: column
        result_map = np.zeros((mask.shape[1], mask.shape[0], self.nb_classes))
        # 0 (background pixel), 128 (face area pixel) or 255 (hair area pixel).
        skin = (mask == 128)
        hair = (mask == 255)

        if self.nb_classes == 2:
            # hair = (mask > 128)
            background = np.logical_not(hair)
            result_map[:, :, 0] = np.where(background, 1, 0)
            result_map[:, :, 1] = np.where(hair, 1, 0)
        elif self.nb_classes == 3:
            background = np.logical_not(hair + skin)
            result_map[:, :, 0] = np.where(background, 1, 0)
            result_map[:, :, 1] = np.where(skin, 1, 0)
            result_map[:, :, 2] = np.where(hair, 1, 0)
        else:
            raise Exception("error...")

        return result_map 
开发者ID:JACKYLUO1991,项目名称:Face-skin-hair-segmentaiton-and-skin-color-evaluation,代码行数:25,代码来源:data_loader.py

示例4: find_outliers_upper_tail

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import logical_not [as 别名]
def find_outliers_upper_tail(mu):

    # remove values that are nan
    I = np.where(np.logical_and(np.logical_not(np.isnan(mu)), np.logical_not(np.isinf(mu))))[0]
    mu = mu[I]

    # calculate mean and sigma
    mean, sigma = mu.mean(), mu.std()

    # calculate the deviation in terms of sigma
    deviation = (mu - mean) / sigma

    # 2 * sigma is considered as an outlier
    S = I[np.where(deviation >= 2)[0]]

    if len(S) == 0 and deviation.max() > 1:
        S = I[[np.argmax(mu)]]

    return S if len(S) > 0 else None 
开发者ID:msu-coinlab,项目名称:pymoo,代码行数:21,代码来源:decision_making.py

示例5: test_class

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import logical_not [as 别名]
def test_class(self):
        """Tests container behavior."""
        model = kproxy_supercell.TDProxy(self.model_krhf, "hf", [self.k, 1, 1], density_fitting_hf)
        model.nroots = self.td_model_krhf.nroots
        assert not model.fast
        model.kernel()
        testing.assert_allclose(model.e, self.td_model_krhf.e, atol=1e-5)
        # Test real
        testing.assert_allclose(model.e.imag, 0, atol=1e-8)

        nocc = nvirt = 4
        testing.assert_equal(model.xy.shape, (len(model.e), 2, self.k, self.k, nocc, nvirt))

        # Test only non-degenerate roots
        d = abs(model.e[1:] - model.e[:-1]) < 1e-8
        d = numpy.logical_or(numpy.concatenate(([False], d)), numpy.concatenate((d, [False])))
        d = numpy.logical_not(d)
        assert_vectors_close(self.td_model_krhf.xy[d], model.xy[d], atol=1e-5) 
开发者ID:pyscf,项目名称:pyscf,代码行数:20,代码来源:test_kproxy_supercell_hf.py

示例6: _node_regr

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import logical_not [as 别名]
def _node_regr(self, configs, wf):
        """ 
        Return true if a given configuration is within nodal_cutoff 
        of the node 
        Also return the regularization polynomial if true, 
        f = a * r ** 2 + b * r ** 4 + c * r ** 3
        """
        ne = configs.configs.shape[1]
        d2 = 0.0
        for e in range(ne):
            d2 += np.sum(wf.gradient(e, configs.electron(e)) ** 2, axis=0)
        r = 1.0 / d2
        mask = r < self.nodal_cutoff ** 2

        c = 7.0 / (self.nodal_cutoff ** 6)
        b = -15.0 / (self.nodal_cutoff ** 4)
        a = 9.0 / (self.nodal_cutoff ** 2)

        f = a * r + b * r ** 2 + c * r ** 3
        f[np.logical_not(mask)] = 1.0

        return mask, f 
开发者ID:WagnerGroup,项目名称:pyqmc,代码行数:24,代码来源:accumulators.py

示例7: color_pcl

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import logical_not [as 别名]
def color_pcl(pcl, K, im, color_axis=0, as_int=True, invalid_color=[0,0,0]):
  uvd = K @ pcl.T
  uvd /= uvd[2]
  uvd = np.round(uvd).astype(np.int32)
  mask = np.logical_and(uvd[0] >= 0, uvd[1] >= 0)
  color = np.empty((pcl.shape[0], 3), dtype=im.dtype)
  if color_axis == 0:
    mask = np.logical_and(mask, uvd[0] < im.shape[2])
    mask = np.logical_and(mask, uvd[1] < im.shape[1])
    uvd = uvd[:,mask]
    color[mask,:] = im[:,uvd[1],uvd[0]].T
  elif color_axis == 2:
    mask = np.logical_and(mask, uvd[0] < im.shape[1])
    mask = np.logical_and(mask, uvd[1] < im.shape[0])
    uvd = uvd[:,mask]
    color[mask,:] = im[uvd[1],uvd[0], :]
  else:
    raise Exception('invalid color_axis')
  color[np.logical_not(mask),:3] = invalid_color
  if as_int:
    color = (255.0 * color).astype(np.int32)
  return color 
开发者ID:autonomousvision,项目名称:connecting_the_dots,代码行数:24,代码来源:geometry.py

示例8: test_subsample_all_examples_dynamic

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import logical_not [as 别名]
def test_subsample_all_examples_dynamic(self):
    numpy_labels = np.random.permutation(300)
    indicator = tf.constant(np.ones(300) == 1)
    numpy_labels = (numpy_labels - 200) > 0

    labels = tf.constant(numpy_labels)

    sampler = (
        balanced_positive_negative_sampler.BalancedPositiveNegativeSampler())
    is_sampled = sampler.subsample(indicator, 64, labels)
    with self.test_session() as sess:
      is_sampled = sess.run(is_sampled)
      self.assertTrue(sum(is_sampled) == 64)
      self.assertTrue(sum(np.logical_and(numpy_labels, is_sampled)) == 32)
      self.assertTrue(sum(np.logical_and(
          np.logical_not(numpy_labels), is_sampled)) == 32) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:18,代码来源:balanced_positive_negative_sampler_test.py

示例9: test_subsample_all_examples_static

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import logical_not [as 别名]
def test_subsample_all_examples_static(self):
    numpy_labels = np.random.permutation(300)
    indicator = np.array(np.ones(300) == 1, np.bool)
    numpy_labels = (numpy_labels - 200) > 0

    labels = np.array(numpy_labels, np.bool)

    def graph_fn(indicator, labels):
      sampler = (
          balanced_positive_negative_sampler.BalancedPositiveNegativeSampler(
              is_static=True))
      return sampler.subsample(indicator, 64, labels)

    is_sampled = self.execute(graph_fn, [indicator, labels])
    self.assertTrue(sum(is_sampled) == 64)
    self.assertTrue(sum(np.logical_and(numpy_labels, is_sampled)) == 32)
    self.assertTrue(sum(np.logical_and(
        np.logical_not(numpy_labels), is_sampled)) == 32) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:20,代码来源:balanced_positive_negative_sampler_test.py

示例10: test_subsample_selection_dynamic

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import logical_not [as 别名]
def test_subsample_selection_dynamic(self):
    # Test random sampling when only some examples can be sampled:
    # 100 samples, 20 positives, 10 positives cannot be sampled
    numpy_labels = np.arange(100)
    numpy_indicator = numpy_labels < 90
    indicator = tf.constant(numpy_indicator)
    numpy_labels = (numpy_labels - 80) >= 0

    labels = tf.constant(numpy_labels)

    sampler = (
        balanced_positive_negative_sampler.BalancedPositiveNegativeSampler())
    is_sampled = sampler.subsample(indicator, 64, labels)
    with self.test_session() as sess:
      is_sampled = sess.run(is_sampled)
      self.assertTrue(sum(is_sampled) == 64)
      self.assertTrue(sum(np.logical_and(numpy_labels, is_sampled)) == 10)
      self.assertTrue(sum(np.logical_and(
          np.logical_not(numpy_labels), is_sampled)) == 54)
      self.assertAllEqual(is_sampled, np.logical_and(is_sampled,
                                                     numpy_indicator)) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:23,代码来源:balanced_positive_negative_sampler_test.py

示例11: test_subsample_selection_static

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import logical_not [as 别名]
def test_subsample_selection_static(self):
    # Test random sampling when only some examples can be sampled:
    # 100 samples, 20 positives, 10 positives cannot be sampled.
    numpy_labels = np.arange(100)
    numpy_indicator = numpy_labels < 90
    indicator = np.array(numpy_indicator, np.bool)
    numpy_labels = (numpy_labels - 80) >= 0

    labels = np.array(numpy_labels, np.bool)

    def graph_fn(indicator, labels):
      sampler = (
          balanced_positive_negative_sampler.BalancedPositiveNegativeSampler(
              is_static=True))
      return sampler.subsample(indicator, 64, labels)

    is_sampled = self.execute(graph_fn, [indicator, labels])
    self.assertTrue(sum(is_sampled) == 64)
    self.assertTrue(sum(np.logical_and(numpy_labels, is_sampled)) == 10)
    self.assertTrue(sum(np.logical_and(
        np.logical_not(numpy_labels), is_sampled)) == 54)
    self.assertAllEqual(is_sampled, np.logical_and(is_sampled, numpy_indicator)) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:24,代码来源:balanced_positive_negative_sampler_test.py

示例12: test_subsample_selection_larger_batch_size_static

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import logical_not [as 别名]
def test_subsample_selection_larger_batch_size_static(self):
    # Test random sampling when total number of examples that can be sampled are
    # less than batch size:
    # 100 samples, 50 positives, 40 positives cannot be sampled, batch size 64.
    # It should still return 64 samples, with 4 of them that couldn't have been
    # sampled.
    numpy_labels = np.arange(100)
    numpy_indicator = numpy_labels < 60
    indicator = np.array(numpy_indicator, np.bool)
    numpy_labels = (numpy_labels - 50) >= 0

    labels = np.array(numpy_labels, np.bool)

    def graph_fn(indicator, labels):
      sampler = (
          balanced_positive_negative_sampler.BalancedPositiveNegativeSampler(
              is_static=True))
      return sampler.subsample(indicator, 64, labels)

    is_sampled = self.execute(graph_fn, [indicator, labels])
    self.assertTrue(sum(is_sampled) == 64)
    self.assertTrue(sum(np.logical_and(numpy_labels, is_sampled)) >= 10)
    self.assertTrue(
        sum(np.logical_and(np.logical_not(numpy_labels), is_sampled)) >= 50)
    self.assertTrue(sum(np.logical_and(is_sampled, numpy_indicator)) == 60) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:27,代码来源:balanced_positive_negative_sampler_test.py

示例13: test_subsample_selection_no_batch_size

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import logical_not [as 别名]
def test_subsample_selection_no_batch_size(self):
    # Test random sampling when only some examples can be sampled:
    # 1000 samples, 6 positives (5 can be sampled).
    numpy_labels = np.arange(1000)
    numpy_indicator = numpy_labels < 999
    indicator = tf.constant(numpy_indicator)
    numpy_labels = (numpy_labels - 994) >= 0

    labels = tf.constant(numpy_labels)

    sampler = (balanced_positive_negative_sampler.
               BalancedPositiveNegativeSampler(0.01))
    is_sampled = sampler.subsample(indicator, None, labels)
    with self.test_session() as sess:
      is_sampled = sess.run(is_sampled)
      self.assertTrue(sum(is_sampled) == 500)
      self.assertTrue(sum(np.logical_and(numpy_labels, is_sampled)) == 5)
      self.assertTrue(sum(np.logical_and(
          np.logical_not(numpy_labels), is_sampled)) == 495)
      self.assertAllEqual(is_sampled, np.logical_and(is_sampled,
                                                     numpy_indicator)) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:23,代码来源:balanced_positive_negative_sampler_test.py

示例14: test_2d_with_missing

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import logical_not [as 别名]
def test_2d_with_missing(self):
        # Test cov on 2D variable w/ missing value
        x = self.data
        x[-1] = masked
        x = x.reshape(3, 4)
        valid = np.logical_not(getmaskarray(x)).astype(int)
        frac = np.dot(valid, valid.T)
        xf = (x - x.mean(1)[:, None]).filled(0)
        assert_almost_equal(cov(x),
                            np.cov(xf) * (x.shape[1] - 1) / (frac - 1.))
        assert_almost_equal(cov(x, bias=True),
                            np.cov(xf, bias=True) * x.shape[1] / frac)
        frac = np.dot(valid.T, valid)
        xf = (x - x.mean(0)).filled(0)
        assert_almost_equal(cov(x, rowvar=False),
                            (np.cov(xf, rowvar=False) *
                             (x.shape[0] - 1) / (frac - 1.)))
        assert_almost_equal(cov(x, rowvar=False, bias=True),
                            (np.cov(xf, rowvar=False, bias=True) *
                             x.shape[0] / frac)) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:22,代码来源:test_extras.py

示例15: test_object_logical

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import logical_not [as 别名]
def test_object_logical(self):
        a = np.array([3, None, True, False, "test", ""], dtype=object)
        assert_equal(np.logical_or(a, None),
                        np.array([x or None for x in a], dtype=object))
        assert_equal(np.logical_or(a, True),
                        np.array([x or True for x in a], dtype=object))
        assert_equal(np.logical_or(a, 12),
                        np.array([x or 12 for x in a], dtype=object))
        assert_equal(np.logical_or(a, "blah"),
                        np.array([x or "blah" for x in a], dtype=object))

        assert_equal(np.logical_and(a, None),
                        np.array([x and None for x in a], dtype=object))
        assert_equal(np.logical_and(a, True),
                        np.array([x and True for x in a], dtype=object))
        assert_equal(np.logical_and(a, 12),
                        np.array([x and 12 for x in a], dtype=object))
        assert_equal(np.logical_and(a, "blah"),
                        np.array([x and "blah" for x in a], dtype=object))

        assert_equal(np.logical_not(a),
                        np.array([not x for x in a], dtype=object))

        assert_equal(np.logical_or.reduce(a), 3)
        assert_equal(np.logical_and.reduce(a), None) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:27,代码来源:test_ufunc.py


注:本文中的numpy.logical_not方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。