def _random_depths(self):
# Pick a random depth
middle = (self._max_depth // 2) + 1
weight = self._max_depth + 1
population = range(weight)
cum_weights = list()
cumulative = 0.8
for d in population:
# first value 0 (zero) will start with default weight
if d <= middle:
cumulative += d
cum_weights.append(cumulative)
else:
cumulative += weight - d
cum_weights.append(cumulative)
return choices(population, cum_weights=cum_weights, k=self.total_items)
评论列表
文章目录