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


Python math.abs方法代碼示例

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


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

示例1: distance

# 需要導入模塊: import math [as 別名]
# 或者: from math import abs [as 別名]
def distance(self, pointA, pointB):
        return math.abs(pointA - pointB) 
開發者ID:BerkeleyLearnVerify,項目名稱:VerifAI,代碼行數:4,代碼來源:features.py

示例2: load_params

# 需要導入模塊: import math [as 別名]
# 或者: from math import abs [as 別名]
def load_params(self):
        path = str(self.load_path.with_suffix('.json').resolve())
        log.info('[loading parameters from {}]'.format(path))
        with open(path, 'r', encoding='utf8') as fp:
            params = json.load(fp)
        for p in self.GRAPH_PARAMS:
            if self.opt.get(p) != params.get(p):
                if p in ('kb_embedding_control_sum') and \
                        (math.abs(self.opt.get(p, 0.) - params.get(p, 0.)) < 1e-3):
                    continue
                raise ConfigError("`{}` parameter must be equal to saved model"
                                  " parameter value `{}`, but is equal to `{}`"
                                  .format(p, params.get(p), self.opt.get(p))) 
開發者ID:deepmipt,項目名稱:DeepPavlov,代碼行數:15,代碼來源:network.py

示例3: next_sample

# 需要導入模塊: import math [as 別名]
# 或者: from math import abs [as 別名]
def next_sample(self):
        """Helper function for reading in next sample."""
        #set total batch size, for example, 1800, and maximum size for each people, for example 45
        if self.seq is not None:
          while True:
            if self.cur >= len(self.seq):
                raise StopIteration
            idx = self.seq[self.cur]
            self.cur += 1
            if self.imgrec is not None:
              s = self.imgrec.read_idx(idx)
              header, img = recordio.unpack(s)
              label = header.label
              if self.output_c2c:
                count = self.idx2flag[idx]
                if self.output_c2c==1:
                  v = np.random.uniform(0.4, 0.5)
                elif self.output_c2c==2:
                  v = np.random.uniform(0.4, 0.5)
                  if count>=self.output_c2c:
                    v = np.random.uniform(0.3, 0.4)
                elif self.output_c2c==3:
                  v = (9.5 - math.log(2.0+count))/10.0
                  v = min(max(v, 0.3), 0.5)
                elif self.output_c2c==4:
                  mu = 0.0
                  sigma = 0.1
                  mrange = [0.4,0.5]
                  v = numpy.random.normal(mu, sigma)
                  v = math.abs(v)*-1.0+mrange[1]
                  v = max(v, mrange[0])
                elif self.output_c2c==5:
                  v = np.random.uniform(0.41, 0.51)
                  if count>=175:
                    v = np.random.uniform(0.37, 0.47)
                elif self.output_c2c==6:
                  v = np.random.uniform(0.41, 0.51)
                  if count>=175:
                    v = np.random.uniform(0.38, 0.48)
                else:
                  assert False

                label = [label, v]
              else:
                if not isinstance(label, numbers.Number):
                  label = label[0]
              return label, img, None, None
            else:
              label, fname, bbox, landmark = self.imglist[idx]
              return label, self.read_image(fname), bbox, landmark
        else:
            s = self.imgrec.read()
            if s is None:
                raise StopIteration
            header, img = recordio.unpack(s)
            return header.label, img, None, None 
開發者ID:deepinsight,項目名稱:insightface,代碼行數:58,代碼來源:data.py


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