本文整理匯總了Python中numpy.core.numeric.zeros方法的典型用法代碼示例。如果您正苦於以下問題:Python numeric.zeros方法的具體用法?Python numeric.zeros怎麽用?Python numeric.zeros使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類numpy.core.numeric
的用法示例。
在下文中一共展示了numeric.zeros方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __setitem__
# 需要導入模塊: from numpy.core import numeric [as 別名]
# 或者: from numpy.core.numeric import zeros [as 別名]
def __setitem__(self, key, val):
ind = self.order - key
if key < 0:
raise ValueError("Does not support negative powers.")
if key > self.order:
zr = NX.zeros(key-self.order, self.coeffs.dtype)
self._coeffs = NX.concatenate((zr, self.coeffs))
ind = 0
self._coeffs[ind] = val
return
示例2: __init__
# 需要導入模塊: from numpy.core import numeric [as 別名]
# 或者: from numpy.core.numeric import zeros [as 別名]
def __init__(self, *shape):
if len(shape) == 1 and isinstance(shape[0], tuple):
shape = shape[0]
x = as_strided(_nx.zeros(1), shape=shape,
strides=_nx.zeros_like(shape))
self._it = _nx.nditer(x, flags=['multi_index', 'zerosize_ok'],
order='C')
示例3: __setitem__
# 需要導入模塊: from numpy.core import numeric [as 別名]
# 或者: from numpy.core.numeric import zeros [as 別名]
def __setitem__(self, key, val):
ind = self.order - key
if key < 0:
raise ValueError("Does not support negative powers.")
if key > self.order:
zr = NX.zeros(key-self.order, self.coeffs.dtype)
self.__dict__['coeffs'] = NX.concatenate((zr, self.coeffs))
self.__dict__['order'] = key
ind = 0
self.__dict__['coeffs'][ind] = val
return
示例4: __init__
# 需要導入模塊: from numpy.core import numeric [as 別名]
# 或者: from numpy.core.numeric import zeros [as 別名]
def __init__(self, *shape):
if len(shape) == 1 and isinstance(shape[0], tuple):
shape = shape[0]
x = as_strided(_nx.zeros(1), shape=shape, strides=_nx.zeros_like(shape))
self._it = _nx.nditer(x, flags=['multi_index', 'zerosize_ok'],
order='C')
示例5: make_mask_none
# 需要導入模塊: from numpy.core import numeric [as 別名]
# 或者: from numpy.core.numeric import zeros [as 別名]
def make_mask_none (s):
"Return a mask of all zeros of shape s."
result = numeric.zeros(s, dtype=MaskType)
result.shape = s
return result
示例6: zeros
# 需要導入模塊: from numpy.core import numeric [as 別名]
# 或者: from numpy.core.numeric import zeros [as 別名]
def zeros (shape, dtype=float):
"""zeros(n, dtype=float) =
an array of all zeros of the given length or shape."""
return array(numeric.zeros(shape, dtype))
示例7: inner
# 需要導入模塊: from numpy.core import numeric [as 別名]
# 或者: from numpy.core.numeric import zeros [as 別名]
def inner(a, b):
"""inner(a,b) returns the dot product of two arrays, which has
shape a.shape[:-1] + b.shape[:-1] with elements computed by summing the
product of the elements from the last dimensions of a and b.
Masked elements are replace by zeros.
"""
fa = filled(a, 0)
fb = filled(b, 0)
if len(fa.shape) == 0: fa.shape = (1,)
if len(fb.shape) == 0: fb.shape = (1,)
return masked_array(numeric.inner(fa, fb))
示例8: dot
# 需要導入模塊: from numpy.core import numeric [as 別名]
# 或者: from numpy.core.numeric import zeros [as 別名]
def dot(a, b):
"""dot(a,b) returns matrix-multiplication between a and b. The product-sum
is over the last dimension of a and the second-to-last dimension of b.
Masked values are replaced by zeros. See also innerproduct.
"""
return innerproduct(filled(a, 0), numeric.swapaxes(filled(b, 0), -1, -2))