本文整理匯總了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:])
示例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)
示例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)
示例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
示例5: max
# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import max [as 別名]
def max(self):
return self._max
示例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
示例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]
示例8: reduce_max
# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import max [as 別名]
def reduce_max(input):
return input.max()
示例9: max
# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import max [as 別名]
def max(input, dim):
return nd.max(input, axis=dim)
示例10: max
# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import max [as 別名]
def max(input, dim):
return tf.reduce_max(input, axis=dim)
示例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
示例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))
示例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
示例14: newmax
# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import max [as 別名]
def newmax(*args, **kwargs):
return new_min_max(_builtin_max, *args, **kwargs)
示例15: max
# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import max [as 別名]
def max(xs):
return builtins.max(xs)