Ejemplo n.º 1
0
func PermanenceMapFromBits(bits data.Bitset) (pm *PermanenceMap) {
	pm = NewPermanenceMap(bits.Len())
	bits.Foreach(func(k int) {
		pm.permanence[k] = pm.config.Initial
	})
	if pm.config.Initial > pm.config.Threshold {
		pm.synapses.Or(bits)
	}
	return pm
}
Ejemplo n.º 2
0
func (g *DistalSegmentGroup) CreateUpdate(sIndex int, activeState data.Bitset, minSynapses int) *SegmentUpdate {
	state := data.NewBitset(activeState.Len())
	if sIndex >= 0 {
		s := g.segments[sIndex]
		state.ResetTo(s.Connected())
	}
	state.Or(activeState)
	for num := state.NumSetBits(); num < minSynapses; num = state.NumSetBits() {
		// TODO(tms): optimize.
		indices := segmentRand.Perm(state.Len())[num:minSynapses]
		state.Set(indices...)
	}
	return NewSegmentUpdate(sIndex, state)
}