Skip to content

Commit

Permalink
Connections: introduce Random rng_ member
Browse files Browse the repository at this point in the history
and use it for synapsesCompetition()
  • Loading branch information
breznak committed Jul 24, 2019
1 parent fd58f25 commit 9a1bbf9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/htm/algorithms/Connections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ void Connections::initialize(CellIdx numCells, Permanence connectedThreshold, bo
connectedThreshold_ = connectedThreshold - htm::Epsilon;
iteration_ = 0;

rng_ = Random(42); //TODO set the seed

nextEventToken_ = 0;

timeseries_ = timeseries;
Expand Down Expand Up @@ -476,7 +478,8 @@ void Connections::adaptSegment(const Segment segment,
}

//balance synapses using competition on dendrite
synapseCompetition(segment, 4, 10); //FIXME derive these numbers
if(rng_.getReal64() < 0.01f) //1% chance //TODO set the probability?
synapseCompetition(segment, 4, 10); //FIXME derive these numbers

//destroy segment if it has too few synapses left -> will never be able to connect again
if(pruneZeroSynapses and synapses.size() < connectedThreshold_) {
Expand Down
3 changes: 2 additions & 1 deletion src/htm/algorithms/Connections.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <htm/types/Types.hpp>
#include <htm/types/Serializable.hpp>
#include <htm/types/Sdr.hpp>
#include <htm/utils/Random.hpp>

namespace htm {

Expand Down Expand Up @@ -715,9 +716,9 @@ class Connections : public Serializable
std::vector<Synapse> destroyedSynapses_;
Permanence connectedThreshold_; //TODO make const
UInt32 iteration_ = 0;
Random rng_;

// Extra bookkeeping for faster computing of segment activity.

struct identity { constexpr size_t operator()( const CellIdx t ) const noexcept { return t; }; }; //TODO in c++20 use std::identity

std::unordered_map<CellIdx, std::vector<Synapse>, identity> potentialSynapsesForPresynapticCell_;
Expand Down

0 comments on commit 9a1bbf9

Please sign in to comment.