Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connections: apply synapsesCompetition() in adaptSegment() #584

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
8 changes: 6 additions & 2 deletions src/htm/algorithms/Connections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,9 @@ void Connections::adaptSegment(const Segment segment,
}
}

//balance synapses using competition on dendrite
synapseCompetition(segment, 8, 11); //FIXME derive these numbers
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the only big remaining issue - how to choose good values for these?
Any tips @ctrl-z-9000-times ?


//destroy synapses accumulated for pruning
for(const auto pruneSyn : destroyLater) {
destroySynapse(pruneSyn);
Expand Down Expand Up @@ -599,7 +602,8 @@ void Connections::synapseCompetition(
const SynapseIdx maximumSynapses)
{
NTA_ASSERT( minimumSynapses <= maximumSynapses);
NTA_ASSERT( maximumSynapses > 0 );
NTA_ASSERT( maximumSynapses >= connectedThreshold );
NTA_ASSERT( minimumSynapses < connectedThreshold );

const auto &segData = dataForSegment( segment );

Expand All @@ -624,7 +628,7 @@ void Connections::synapseCompetition(
// Can't connect more synapses than there are in the potential pool.
desiredConnected = std::min( (SynapseIdx) segData.synapses.size(), desiredConnected);
// The N'th synapse is at index N-1
if( desiredConnected != 0 ) {
if( desiredConnected > 0 ) {
desiredConnected--;
}
// else {
Expand Down
4 changes: 2 additions & 2 deletions src/htm/algorithms/Connections.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ class Connections : public Serializable
* @param increment Change in permanence for synapses with active presynapses.
* @param decrement Change in permanence for synapses with inactive presynapses.
* @param pruneZeroSynapses (default false) If set, synapses that reach minPermanence(aka. "zero")
* are removed. This is used in TemporalMemory.
* are removed. This is used in TemporalMemory and SpatialPooler.
* @param segmentThreshold (optional) (default 0) Minimum number of connected synapses for a segment
* to be considered active. @see raisePermenencesToThreshold(). Equivalent to `SP.stimulusThreshold`.
* If `pruneZeroSynapses` is used and synapses are removed, if the amount of synapses drops below
Expand Down Expand Up @@ -523,7 +523,7 @@ class Connections : public Serializable
*/
void synapseCompetition( const Segment segment,
const SynapseIdx minimumSynapses,
const SynapseIdx maximumSynapses);
const SynapseIdx maximumSynapses);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO

  • this should have some parametric default values
  • replace (or provide overload) with percentages off the range [stimulusThreshold, maxSynapsesPerSegment]?



/**
Expand Down
2 changes: 1 addition & 1 deletion src/htm/algorithms/SpatialPooler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ Real SpatialPooler::avgConnectedSpanForColumnND_(const UInt column) const {
void SpatialPooler::adaptSynapses_(const SDR &input,
const SDR &active) {
for(const auto &column : active.getSparse()) {
connections_.adaptSegment(column, input, synPermActiveInc_, synPermInactiveDec_);
connections_.adaptSegment(column, input, synPermActiveInc_, synPermInactiveDec_, true);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SP also does prune synapses (like TM)

  • default to true/or even rm the parameter, when all use true now

connections_.raisePermanencesToThreshold( column, stimulusThreshold_ );
}
}
Expand Down