本文整理汇总了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