/// <summary> /// Performs the remote initialization ot the SP on actor nodes. /// </summary> /// <param name="c"></param> /// <param name="distMem"></param> public override void InitMatrices(Connections c, DistributedMemory distMem) { IHtmDistCalculus remoteHtm = distMem?.ColumnDictionary as IHtmDistCalculus; if (remoteHtm == null) { throw new ArgumentException("Must implement IHtmDistCalculus!"); } this.distMemConfig = distMem; SparseObjectMatrix <Column> mem = (SparseObjectMatrix <Column>)c.HtmConfig.Memory; c.HtmConfig.Memory = mem == null ? mem = new SparseObjectMatrix <Column>(c.HtmConfig.ColumnDimensions, dict: distMem.ColumnDictionary) : mem; c.HtmConfig.InputMatrix = new SparseBinaryMatrix(c.HtmConfig.InputDimensions); // Initiate the topologies c.HtmConfig.ColumnTopology = new Topology(c.HtmConfig.ColumnDimensions); c.HtmConfig.InputTopology = new Topology(c.HtmConfig.InputDimensions); //Calculate numInputs and numColumns int numInputs = c.HtmConfig.InputMatrix.GetMaxIndex() + 1; int numColumns = c.HtmConfig.Memory.GetMaxIndex() + 1; if (numColumns <= 0) { throw new ArgumentException("Invalid number of columns: " + numColumns); } if (numInputs <= 0) { throw new ArgumentException("Invalid number of inputs: " + numInputs); } c.HtmConfig.NumInputs = numInputs; c.HtmConfig.NumColumns = numColumns; if (distMem != null) { //var distHtmCla = distMem.ColumnDictionary as HtmSparseIntDictionary<Column>; var distHtmCla = distMem.ColumnDictionary;// as ActorSbDistributedDictionaryBase<Column>; distHtmCla.HtmConfig = c.HtmConfig; } // // Fill the sparse matrix with column objects //var numCells = c.getCellsPerColumn(); // var partitions = mem.GetPartitions(); List <KeyPair> colList = new List <KeyPair>(); for (int i = 0; i < numColumns; i++) { //colList.Add(new KeyPair() { Key = i, Value = new Column(numCells, i, c.getSynPermConnected(), c.NumInputs) }); colList.Add(new KeyPair() { Key = i, Value = c.HtmConfig }); } Stopwatch sw = new Stopwatch(); sw.Start(); remoteHtm.InitializeColumnPartitionsDist(colList); //mem.set(colList); sw.Stop(); //c.setPotentialPools(new SparseObjectMatrix<Pool>(c.getMemory().getDimensions(), dict: distMem == null ? null : distMem.PoolDictionary)); Debug.WriteLine($" Upload time: {sw.ElapsedMilliseconds}"); // Already initialized by creating of columns. //c.setConnectedMatrix(new SparseBinaryMatrix(new int[] { numColumns, numInputs })); //Initialize state meta-management statistics c.HtmConfig.OverlapDutyCycles = new double[numColumns]; c.HtmConfig.ActiveDutyCycles = new double[numColumns]; c.HtmConfig.MinOverlapDutyCycles = new double[numColumns]; c.HtmConfig.MinActiveDutyCycles = new double[numColumns]; c.BoostFactors = (new double[numColumns]); ArrayUtils.FillArray(c.BoostFactors, 1); }
/// <summary> /// Uses the same implementation as Single-Threaded. /// </summary> /// <param name="c"></param> /// <param name="distMem"></param> public override void InitMatrices(Connections c, DistributedMemory distMem) { base.InitMatrices(c, distMem); }