本文整理匯總了Python中bottleneck.nansum方法的典型用法代碼示例。如果您正苦於以下問題:Python bottleneck.nansum方法的具體用法?Python bottleneck.nansum怎麽用?Python bottleneck.nansum使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類bottleneck
的用法示例。
在下文中一共展示了bottleneck.nansum方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _update_inhibition_radius
# 需要導入模塊: import bottleneck [as 別名]
# 或者: from bottleneck import nansum [as 別名]
def _update_inhibition_radius(self):
"""
Sets the inhibition radius based off the average receptive field size.
The average receptive field size is the distance of the connected
synapses with respect to to their input column. In other words, it is
the distance between a column and its input source averaged across all
connected synapses. The distance used is the Euclidean distance. Refer
to the initialization of self.syn_dist for more details.
NOTE
- This should only be called after phase 1.
- The minimum inhibition radius is lower-bounded by 1.
"""
self.inhibition_radius = max(bn.nansum(self.syn_dist * self.syn_c) /
max(bn.nansum(self.syn_c), 1), 1)
示例2: _phase1
# 需要導入模塊: import bottleneck [as 別名]
# 或者: from bottleneck import nansum [as 別名]
def _phase1(self):
"""
Execute phase 1 of the SP region. This phase is used to compute the
overlap.
Note - This should only be called once the input has been updated.
"""
# Compute the connected synapse mask
self.syn_c = self.p >= self.syn_th
# Compute the overlaps
self.overlap[:, 1:] = self.overlap[:, :-1] # Shift
self.overlap[:, 0] = bn.nansum(self.x[self.syn_map] * self.syn_c, 1)
self.overlap[:, 0][self.overlap[:, 0] < self.seg_th] = 0
self.overlap[:, 0] = self.overlap[:, 0] * self.boost
示例3: sum
# 需要導入模塊: import bottleneck [as 別名]
# 或者: from bottleneck import nansum [as 別名]
def sum(self, **kwargs):
"""Return sum of non-NaN elements."""
return self.wrap_reduced(nansum(self.to_2d_array(), axis=0), **kwargs)
示例4: _pixel_distribution
# 需要導入模塊: import bottleneck [as 別名]
# 或者: from bottleneck import nansum [as 別名]
def _pixel_distribution(dataset, tolerance=0.001, min_frames=1000):
"""Estimate the distribution of pixel intensities for each channel.
Parameters
----------
tolerance : float
The maximum relative error in the estimates that must be
achieved for termination.
min_frames: int
The minimum number of frames that must be evaluated before
termination.
Returns
-------
mean_est : array
Mean intensities of each channel.
var_est :
Variances of the intensity of each channel.
"""
# TODO: separate distributions for each plane
sums = np.zeros(dataset.frame_shape[-1]).astype(float)
sum_squares = np.zeros_like(sums)
counts = np.zeros_like(sums)
t = 0
for frame in it.chain.from_iterable(dataset):
for plane in frame:
if t > 0:
mean_est = sums / counts
var_est = (sum_squares / counts) - (mean_est ** 2)
if t > min_frames and np.all(
np.sqrt(var_est / counts) / mean_est < tolerance):
break
sums += np.nan_to_num(nansum(nansum(plane, axis=0), axis=0))
sum_squares += np.nan_to_num(
nansum(nansum(plane ** 2, axis=0), axis=0))
counts += np.isfinite(plane).sum(axis=0).sum(axis=0)
t += 1
assert np.all(mean_est > 0)
assert np.all(var_est > 0)
return mean_est, var_est