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


Python builtins.max方法代码示例

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


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

示例1: pad_packed_tensor

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import max [as 别名]
def pad_packed_tensor(input, lengths, value, l_min=None):
    old_shape = input.shape
    if isinstance(lengths, th.Tensor):
        max_len = as_scalar(lengths.max())
    else:
        max_len = builtins.max(lengths)

    if l_min is not None:
        max_len = builtins.max(max_len, l_min)

    batch_size = len(lengths)
    device = input.device
    x = input.new(batch_size * max_len, *old_shape[1:])
    x.fill_(value)
    index = []
    for i, l in enumerate(lengths):
        index.extend(range(i * max_len, i * max_len + l))
    index = th.tensor(index).to(device)
    return scatter_row(x, index, input).view(batch_size, max_len, *old_shape[1:]) 
开发者ID:dmlc,项目名称:dgl,代码行数:21,代码来源:tensor.py

示例2: _tree_reduction

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import max [as 别名]
def _tree_reduction(cls, tensor, axis):
        op = tensor.op
        kw = getattr(op, '_get_op_kw')() or {}
        keepdims = op.keepdims
        combine_size = op.combine_size or options.combine_size
        if isinstance(combine_size, dict):
            combine_size = dict((ax, combine_size.get(ax)) for ax in axis)
        else:
            assert isinstance(combine_size, int)
            n = builtins.max(int(combine_size ** (1.0 / (len(axis) or 1))), 2)
            combine_size = dict((ax, n) for ax in axis)

        times = 1
        for i, n in enumerate(tensor.chunk_shape):
            if i in combine_size and combine_size[i] != 1:
                times = int(builtins.max(times, ceil(log(n, combine_size[i]))))

        for i in range(times - 1):
            [tensor] = cls._partial_reduction(tensor, axis, op.dtype, True, combine_size, OperandStage.combine)

        return cls._partial_reduction(tensor, axis, op.dtype, keepdims, combine_size, OperandStage.agg, kw) 
开发者ID:mars-project,项目名称:mars,代码行数:23,代码来源:core.py

示例3: pad_packed_tensor

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import max [as 别名]
def pad_packed_tensor(input, lengths, value, l_min=None):
    old_shape = input.shape
    if isinstance(lengths, tf.Tensor):
        max_len = as_scalar(lengths.max())
    else:
        max_len = builtins.max(lengths)

    if l_min is not None:
        max_len = builtins.max(max_len, l_min)

    batch_size = len(lengths)
    ndim = input.ndim
    tensor_list = []
    cum_row = 0
    pad_nparray = np.zeros((ndim, 2), dtype=np.int32)
    for l in lengths:
        t = input[cum_row:cum_row+l]
        pad_nparray[0, 1] = max_len - l
        t = tf.pad(t, tf.constant(pad_nparray),
                   mode='CONSTANT', constant_values=value)
        tensor_list.append(t)
        cum_row += l
    return tf.stack(tensor_list, axis=0) 
开发者ID:dmlc,项目名称:dgl,代码行数:25,代码来源:tensor.py

示例4: __init__

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import max [as 别名]
def __init__(self, val=0, min=None, max=None, _nrbits=0):
        if _nrbits:
            self._min = 0
            self._max = 2**_nrbits
        else:
            self._min = min
            self._max = max
            if max is not None and min is not None:
                if min >= 0:
                    _nrbits = len(bin(max - 1))
                elif max <= 1:
                    _nrbits = len(bin(min))
                else:
                    # make sure there is a leading zero bit in positive numbers
                    _nrbits = builtins.max(len(bin(max - 1)) + 1, len(bin(min)))
        if isinstance(val, int):
            self._val = val
        elif isinstance(val, str):
            mval = val.replace('_', '')
            self._val = int(mval, 2)
            _nrbits = len(mval)
        elif isinstance(val, intbv):
            self._val = val._val
            self._min = val._min
            self._max = val._max
            _nrbits = val._nrbits
        else:
            raise TypeError("intbv constructor arg should be int or string")
        self._nrbits = _nrbits
        self._handleBounds()

    # support for the 'min' and 'max' attribute 
开发者ID:myhdl,项目名称:myhdl,代码行数:34,代码来源:_intbv.py

示例5: max

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import max [as 别名]
def max(self):
        return self._max 
开发者ID:myhdl,项目名称:myhdl,代码行数:4,代码来源:_intbv.py

示例6: _hasFullRange

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import max [as 别名]
def _hasFullRange(self):
        min, max = self._min, self._max
        if max <= 0:
            return False
        if min not in (0, -max):
            return False
        return max & max - 1 == 0

    # hash 
开发者ID:myhdl,项目名称:myhdl,代码行数:11,代码来源:_intbv.py

示例7: max

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import max [as 别名]
def max(input, dim):
    # NOTE: the second argmax array is not returned
    return th.max(input, dim=dim)[0] 
开发者ID:dmlc,项目名称:dgl,代码行数:5,代码来源:tensor.py

示例8: reduce_max

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import max [as 别名]
def reduce_max(input):
    return input.max() 
开发者ID:dmlc,项目名称:dgl,代码行数:4,代码来源:tensor.py

示例9: max

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import max [as 别名]
def max(input, dim):
    return nd.max(input, axis=dim) 
开发者ID:dmlc,项目名称:dgl,代码行数:4,代码来源:tensor.py

示例10: max

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import max [as 别名]
def max(input, dim):
    return tf.reduce_max(input, axis=dim) 
开发者ID:dmlc,项目名称:dgl,代码行数:4,代码来源:tensor.py

示例11: sync_node_time

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import max [as 别名]
def sync_node_time(cluster):
    hosts = C_Host.objects.filter(
        Q(project_id=cluster.id) & ~Q(name='localhost') & ~Q(name='127.0.0.1') & ~Q(name='::1'))
    data = []
    times = []
    result = {
        'success': True,
        'data': []
    }
    for host in hosts:
        ssh_config = SshConfig(host=host.ip, port=host.port, username=host.username, password=host.password,
                               private_key=None)

        ssh_client = SSHClient(ssh_config)
        res = ssh_client.run_cmd('date')
        gmt_date = res[0]
        GMT_FORMAT = '%a %b %d %H:%M:%S CST %Y'
        date = time.strptime(gmt_date, GMT_FORMAT)
        timeStamp = int(time.mktime(date))
        times.append(timeStamp)
        show_time = time.strftime('%Y-%m-%d %H:%M:%S', date)
        time_data = {
            'hostname': host.name,
            'date': show_time,
        }
        data.append(time_data)
    result['data'] = data
    max = builtins.max(times)
    min = builtins.min(times)
    # 如果最大值减最小值超过5分钟 则判断有错
    if (max - min) > 300000:
        result['success'] = False
    return result 
开发者ID:KubeOperator,项目名称:KubeOperator,代码行数:35,代码来源:cluster_monitor.py

示例12: max

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import max [as 别名]
def max(a, axis=None, out=None, keepdims=False):
    return (a, mark_non_coercible(out)) 
开发者ID:Quansight-Labs,项目名称:unumpy,代码行数:4,代码来源:_multimethods.py

示例13: _ptp_default

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import max [as 别名]
def _ptp_default(a, axis=None, out=None, keepdims=False):
    result = max(a, axis=axis, out=out, keepdims=keepdims)
    result -= min(a, axis=axis, out=None, keepdims=keepdims)
    return result 
开发者ID:Quansight-Labs,项目名称:unumpy,代码行数:6,代码来源:_multimethods.py

示例14: newmax

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import max [as 别名]
def newmax(*args, **kwargs):
    return new_min_max(_builtin_max, *args, **kwargs) 
开发者ID:alfa-addon,项目名称:addon,代码行数:4,代码来源:new_min_max.py

示例15: max

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import max [as 别名]
def max(xs):
    return builtins.max(xs) 
开发者ID:jackfirth,项目名称:pyramda,代码行数:4,代码来源:max.py


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