python类inf()的实例源码

callbacks.py 文件源码 项目:keras 作者: GeekLiB 项目源码 文件源码 阅读 44 收藏 0 点赞 0 评论 0
def __init__(self, filepath, monitor='val_loss', verbose=0,
                 save_best_only=False, save_weights_only=False,
                 mode='auto'):
        super(ModelCheckpoint, self).__init__()
        self.monitor = monitor
        self.verbose = verbose
        self.filepath = filepath
        self.save_best_only = save_best_only
        self.save_weights_only = save_weights_only

        if mode not in ['auto', 'min', 'max']:
            warnings.warn('ModelCheckpoint mode %s is unknown, '
                          'fallback to auto mode.' % (mode),
                          RuntimeWarning)
            mode = 'auto'

        if mode == 'min':
            self.monitor_op = np.less
            self.best = np.Inf
        elif mode == 'max':
            self.monitor_op = np.greater
            self.best = -np.Inf
        else:
            if 'acc' in self.monitor:
                self.monitor_op = np.greater
                self.best = -np.Inf
            else:
                self.monitor_op = np.less
                self.best = np.Inf
callbacks.py 文件源码 项目:keras 作者: GeekLiB 项目源码 文件源码 阅读 36 收藏 0 点赞 0 评论 0
def on_train_begin(self, logs={}):
        self.wait = 0       # Allow instances to be re-used
        self.best = np.Inf if self.monitor_op == np.less else -np.Inf
callbacks.py 文件源码 项目:keras 作者: GeekLiB 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def reset(self):
        if self.mode not in ['auto', 'min', 'max']:
            warnings.warn('Learning Rate Plateau Reducing mode %s is unknown, '
                          'fallback to auto mode.' % (self.mode), RuntimeWarning)
            self.mode = 'auto'
        if self.mode == 'min' or (self.mode == 'auto' and 'acc' not in self.monitor):
            self.monitor_op = lambda a, b: np.less(a, b - self.epsilon)
            self.best = np.Inf
        else:
            self.monitor_op = lambda a, b: np.greater(a, b + self.epsilon)
            self.best = -np.Inf
        self.cooldown_counter = 0
        self.wait = 0
        self.lr_epsilon = self.min_lr * 1e-4
cma_es_lib.py 文件源码 项目:third_person_im 作者: bstadie 项目源码 文件源码 阅读 39 收藏 0 点赞 0 评论 0
def _get_bounds(self, ib, dimension):
        """ib == 0/1 means lower/upper bound, return a vector of length
        `dimension` """
        sign_ = 2 * ib - 1
        assert sign_**2 == 1
        if self.bounds is None or self.bounds[ib] is None:
            return array(dimension * [sign_ * np.Inf])
        res = []
        for i in range(dimension):
            res.append(self.bounds[ib][min([i, len(self.bounds[ib]) - 1])])
            if res[-1] is None:
                res[-1] = sign_ * np.Inf
        return array(res)
data.py 文件源码 项目:dtnn 作者: atomistic-machine-learning 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def __init__(self, asedb, kvp={}, data={}, batch_size=1,
                 selection=None, shuffle=True, prefetch=False,
                 block_size=150000,
                 capacity=5000, num_epochs=np.Inf, floatX=np.float32):
        super(ASEDataProvider, self).__init__(batch_size)

        self.asedb = asedb
        self.prefetch = prefetch
        self.selection = selection
        self.block_size = block_size
        self.shuffle = shuffle
        self.kvp = kvp
        self.data = data
        self.floatX = floatX
        self.feat_names = ['numbers', 'positions', 'cell',
                           'pbc'] + list(kvp.keys()) + list(data.keys())
        self.shapes = [(None,), (None, 3), (3, 3),
                       (3,)] + list(kvp.values()) + list(data.values())

        self.epoch = 0
        self.num_epochs = num_epochs
        self.n_rows = 0

        # initialize queue
        with connect(self.asedb) as con:
            row = list(con.select(self.selection, limit=1))[0]

        feats = self.convert_atoms(row)
        dtypes = [np.array(feat).dtype for feat in feats]
        self.queue = tf.FIFOQueue(capacity, dtypes)

        self.placeholders = [
            tf.placeholder(dt, name=name)
            for dt, name in zip(dtypes, self.feat_names)
            ]
        self.enqueue_op = self.queue.enqueue(self.placeholders)
        self.dequeue_op = self.queue.dequeue()

        self.preprocs = []
utilitiesClass.py 文件源码 项目:pslab-desktop-apps 作者: fossasia 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def read(self):
            retval = self.func()
            if isinstance(retval,numbers.Number) and retval != np.Inf:self.value.setText('%s'%(self.applySIPrefix(retval,self.units) ))
            else: self.value.setText(str(retval))
utilitiesClass.py 文件源码 项目:pslab-desktop-apps 作者: fossasia 项目源码 文件源码 阅读 39 收藏 0 点赞 0 评论 0
def read(self):
            retval = self.func()
            try:
                if isinstance(retval,numbers.Number) and retval != np.Inf:self.value.setText('%s'%(self.applySIPrefix(retval,self.units) ))
                else: self.value.setText(retval)
            except:self.value.setText(str(retval))
utilitiesClass.py 文件源码 项目:pslab-desktop-apps 作者: fossasia 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def read(self):
            retval = self.func(self.optionBox.currentText())
            #if abs(retval)<1e4 and abs(retval)>.01:self.value.setText('%.3f %s '%(retval,self.units))
            #else: self.value.setText('%.3e %s '%(retval,self.units))
            if isinstance(retval,numbers.Number) and retval != np.Inf:self.value.setText('%s'%(self.applySIPrefix(retval,self.units) ))
            else: self.value.setText(str(retval))
            if self.linkFunc:
                self.linkFunc(retval)
evaluate.py 文件源码 项目:source_separation_ml_jeju 作者: hjkwon0609 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def _safe_db(num, den):
    """Properly handle the potential +Inf db SIR, instead of raising a
    RuntimeWarning. Only denominator is checked because the numerator can never
    be 0.
    """
    if den == 0:
        return np.Inf
    return 10 * np.log10(num / den)
cma_es_lib.py 文件源码 项目:rllabplusplus 作者: shaneshixiang 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def _get_bounds(self, ib, dimension):
        """ib == 0/1 means lower/upper bound, return a vector of length
        `dimension` """
        sign_ = 2 * ib - 1
        assert sign_**2 == 1
        if self.bounds is None or self.bounds[ib] is None:
            return array(dimension * [sign_ * np.Inf])
        res = []
        for i in range(dimension):
            res.append(self.bounds[ib][min([i, len(self.bounds[ib]) - 1])])
            if res[-1] is None:
                res[-1] = sign_ * np.Inf
        return array(res)


问题


面经


文章

微信
公众号

扫码关注公众号