From e0abc8bbbf14c4d6efffb7751839569715790c45 Mon Sep 17 00:00:00 2001 From: david-ragazzi Date: Thu, 26 Feb 2015 22:21:25 -0300 Subject: [PATCH 001/100] Remove old SPs --- src/nupic/algorithms/FDRCSpatial.hpp | 1796 -------------------------- src/nupic/algorithms/FDRSpatial.hpp | 1000 -------------- 2 files changed, 2796 deletions(-) delete mode 100644 src/nupic/algorithms/FDRCSpatial.hpp delete mode 100644 src/nupic/algorithms/FDRSpatial.hpp diff --git a/src/nupic/algorithms/FDRCSpatial.hpp b/src/nupic/algorithms/FDRCSpatial.hpp deleted file mode 100644 index 0886860962..0000000000 --- a/src/nupic/algorithms/FDRCSpatial.hpp +++ /dev/null @@ -1,1796 +0,0 @@ -/* --------------------------------------------------------------------- - * Numenta Platform for Intelligent Computing (NuPIC) - * Copyright (C) 2013, Numenta, Inc. Unless you have an agreement - * with Numenta, Inc., for a separate license for this software code, the - * following terms and conditions apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 3 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses. - * - * http://numenta.org/licenses/ - * --------------------------------------------------------------------- - */ - -#ifndef NTA_FDR_C_SPATIAL_HPP -#define NTA_FDR_C_SPATIAL_HPP - -#include - -#if defined(NTA_ARCH_64) && defined(NTA_OS_LINUX) -#define P_INC 4 // TODO: set for other 64bits too? Or set to sizeof(int*) instead? -#else -#define P_INC 2 -#endif - -namespace nupic { - namespace algorithms { - - //-------------------------------------------------------------------------------- - /** - * The FDRSpatial class stores binary 0/1 coincidences and computes the degree - * of match between an input vector (binary 0/1) and each coincidence, to output - * a sparse (binary 0/1) "representation" of the input vector in terms of the - * coincidences. The degree of match is simply the number of bits that overlap - * between each coincidence and the input vector. Only the top-N best matches are - * turned on in the output, and the outputs always have the same, fixed number - * of bits turned on (N), according to FDR principles. - * - * The coincidences can be learnt, in which case the non-zeros of the coincidences - * that match the inputs best are reinforced while others are gradually forgotten. - * Learning is online and the coincidences can adapt to the changing statistics - * of the inputs. - * - * NOTE: - * there are two thresholds used in this class: - * - stimulus_threshold is used to decide whether a coincidence matches the - * input vector well enough or not. It is a hurdle that the coincidence has - * to pass in order to participate in the representation of the input, removing - * coincidences that would have only an insignificant number of bits matching - * the input. - * - histogram_threshold is used, with learning only, to decide which bits from - * the coincidences are more important and can participate in matching the - * input. Bits with a count lower than histogram_threshold are kept in the - * coincidence, but they do not participate to match the input. - * - * IMPLEMENTATION NOTE: - * Each row (coincidence) has exactly nnzpr non-zeros. - * The non-zeros are represented by pairs (index,count) of type (uint,float), - * and we call that type 'IndNZ'. Since all the rows have the same number of - * non-zeros, we use a compact storage where all the non-zeros are stored in - * a vector (of immutable size = nrows * nnzpr), and this vector is called - * 'ind_nz'. The k-th non-zero of row i is at position: ind_nz[i*nnzpr+k]. - * - * IMPLEMENTATION NOTE: - * In order to optimize speed, the non-zeros of each coincidence are stored in - * such a way that the non-zeros which have a count > histogram_threshold appear - * first, and the others after. The boundary between those two sets is maintained - * in ub[i] for each row i. These two sets are updated in update(). In infer(), - * only the non-zeros up to ub[i] are used to compute the match of coincidence i - * and the input vector. - */ - - //-------------------------------------------------------------------------------- - /* - struct Timer - { - struct timeval t0, t1; - - inline Timer() { gettimeofday(&t0, NULL); } - inline void start() { gettimeofday(&t0, NULL); } - inline void restart() { gettimeofday(&t0, NULL); } - inline double elapsed() - { - gettimeofday(&t1, NULL); - return t1.tv_sec+1e-6*t1.tv_usec - (t0.tv_sec+1e-6*t0.tv_usec); - } - }; - */ - - //-------------------------------------------------------------------------------- - class Inhibition - { - public: - typedef nupic::UInt32 size_type; - typedef nupic::Real32 value_type; - - private: - size_type small; - size_type c_height, c_width, c_field_size; - size_type inhibition_radius; - std::vector > inhibition_area; - - public: - //-------------------------------------------------------------------------------- - inline Inhibition(size_type _c_height =0, size_type _c_width =0, - value_type _desired_density =1.0f, - size_type _small =0) - { - initialize(_c_height, _c_width, _desired_density, _small); - } - - //-------------------------------------------------------------------------------- - inline void initialize(size_type _c_height =0, size_type _c_width =0, - value_type _desired_density =1.0f, - size_type _small =0) - { - small = _small; - c_height = _c_height; - c_width = _c_width; - c_field_size = c_height * c_width; - inhibition_radius = size_type(sqrt(1.0f/_desired_density) - 1.0f); - - if (estimate_max_size_bytes() > 600*1024*1024) - small = 1; - - if (small == 1) { - inhibition_area.resize(0); - return; - } - - inhibition_area.resize(c_field_size); - - for (size_type c = 0; c != c_field_size; ++c) { - - // so that we can reinitialize, for example when - // we change the desired density - inhibition_area[c].resize(0); - - int ch = c / c_width; - int cw = c % c_width; - int lb_height = std::max((int) 0, ch - (int) inhibition_radius); - int ub_height = std::min(ch + inhibition_radius + 1, c_height); - int lb_width = std::max((int) 0, cw - (int) inhibition_radius); - int ub_width = std::min(cw + inhibition_radius + 1, c_width); - - for (int py = lb_height; py != ub_height; ++py) { - for (int px = lb_width; px != ub_width; ++px) { - int w = px + c_width * py; - if (w != (int) c) - inhibition_area[c].push_back(w); - } - } - } - } - - //-------------------------------------------------------------------------------- - inline int getSmall() const { return small; } - inline size_type getInhibitionRadius() const { return inhibition_radius; } - inline size_type getHeight() const { return c_height; } - inline size_type getWidth() const { return c_width; } - inline size_type n_bytes() const { return nupic::n_bytes(inhibition_area); } - - //-------------------------------------------------------------------------------- - inline size_type estimate_max_size_bytes() const - { - size_type a = 0; - - for (size_type c = 0; c != c_field_size; ++c) { - - int ch = c / c_width; - int cw = c % c_width; - int lb_height = std::max((int) 0, ch - (int) inhibition_radius); - int ub_height = std::min(ch + inhibition_radius + 1, c_height); - int lb_width = std::max((int) 0, cw - (int) inhibition_radius); - int ub_width = std::min(cw + inhibition_radius + 1, c_width); - - a += (ub_height - lb_height) * (ub_width - lb_width); - } - - return a * sizeof(int); - } - - //-------------------------------------------------------------------------------- - inline void setDesiredOutputDensity(value_type v) - { - initialize(c_height, c_width, v, small); - } - - //-------------------------------------------------------------------------------- - /* - * TODO: precompute deltas on which to compute the max, or - * sometimes compute on a whole square if max was in the delta - * removed. This retests the same pixels over and over again. - * Don't forget that there are deltas added and deltas removed. - * Maybe store the indices of the columns in inhibition radius - * as well as the deltas. - * TODO: as soon as greater value than y[c] / .95 found in the new - * delta, cell is inhibited - */ - template - inline size_type compute(It1 x, It2 y, size_type stimulus_threshold =0, - value_type k =.95f) - { - size_type n_active = 0; - - if (small == 0) { - - for (size_type c = 0; c != c_field_size; ++c) { - - if (x[c] <= stimulus_threshold) - continue; - - value_type val_c = x[c] / k; - size_type* w = &inhibition_area[c][0]; - size_type* w_end = w + inhibition_area[c].size(); - - while (w != w_end && val_c > x[*w]) - ++w; - - if (w == w_end) - y[n_active++] = c; - } - - } else if (small == 1) { - - for (size_type c = 0; c != c_field_size; ++c) { - - if (x[c] <= stimulus_threshold) - continue; - - value_type val_c = x[c] / k; - - int ch = c / c_width; - int cw = c % c_width; - int lb_height = std::max((int) 0, ch - (int) inhibition_radius); - int ub_height = std::min(ch + inhibition_radius + 1, c_height); - int lb_width = std::max((int) 0, cw - (int) inhibition_radius); - int ub_width = std::min(cw + inhibition_radius + 1, c_width); - - bool stop = false; - - for (int px = lb_width; px != ub_width && !stop; ++px) { - for (int py = lb_height; py != ub_height && !stop; ++py) { - size_type w = (size_type) px + c_width * (size_type) py; - if (w == c) - continue; - stop = val_c <= x[w]; - } - } - - if (!stop) - y[n_active++] = c; - } - } - - return n_active; - } - }; - - //-------------------------------------------------------------------------------- - // used for the old-fashioned sort in Inhibition2::compute() - // - // We would put this inside the function, but gcc 4.5 busts us. - // A language lawyer explains that C++98/03 (the current one) does - // not allow instantiation of a template with a local type. - template - struct CMySort - { - typedef nupic::UInt32 size_type; - It _x; - CMySort(It& x) : _x(x) {} - bool operator()(size_type A, size_type B) const { - return _x[A] > _x[B]; - } - }; - - //-------------------------------------------------------------------------------- - //-------------------------------------------------------------------------------- - /* - * This class implements cell inhibition. Given a region of cells and their - * firing strengths, it returns the list of indices of the cells that are - * firing after inhibition. - * - * Inhibition is computed per "inhibition area" within the layer. The - * size of the inhibition area is controlled by the '_inhibition_radius' - * construction parameter. An inhibition area is a square section of cells - * with a width and height of (_inhibition_radius * 2 + 1). - * - * A cell is only allowed to fire if it is among the top N% strongest cells - * within the inhibition area centered around itself, where N is given by the - * construction parameter '_local_area_density'. - * - */ - class Inhibition2 - { - public: - typedef nupic::UInt32 size_type; - typedef nupic::Real32 value_type; - - private: - size_type c_height, c_width, c_field_size; - size_type inhibition_radius; - value_type local_area_density; - - public: - //-------------------------------------------------------------------------------- - // Parameters: - // _c_height: height of the region, in cells - // _c_width: width of the region, in cells - // _inhibition_radius: inhibition radius, in cells - // _local_area_density: desired local area density within each - // inhibition area. - // - inline Inhibition2(size_type _c_height =0, size_type _c_width =0, - size_type _inhibition_radius =10, - value_type _local_area_density =0.02f) - { - initialize(_c_height, _c_width, _inhibition_radius, _local_area_density); - } - - //-------------------------------------------------------------------------------- - // Parameters: - // _c_height: height of the region, in cells - // _c_width: width of the region, in cells - // _inhibition_radius: inhibition radius, in cells - // _local_area_density: desired local area density within each - // inhibition area. - // - inline void initialize(size_type _c_height =0, size_type _c_width =0, - size_type _inhibition_radius =10, - value_type _local_area_density =0.02f) - { - NTA_ASSERT(0 < _local_area_density && _local_area_density <= 1); - - c_height = _c_height; - c_width = _c_width; - c_field_size = c_height * c_width; - inhibition_radius = _inhibition_radius; - local_area_density = _local_area_density; - } - - //-------------------------------------------------------------------------------- - // Various getter methods - inline size_type getInhibitionRadius() const { return inhibition_radius; } - inline value_type getLocalAreaDensity() const { return local_area_density; } - inline size_type getHeight() const { return c_height; } - inline size_type getWidth() const { return c_width; } - - //-------------------------------------------------------------------------------- - // Modify the desired local area density. - inline void setDesiredOutputDensity(value_type v) - { - initialize(c_height, c_width, inhibition_radius, v); - } - - //-------------------------------------------------------------------------------- - // Compute which cells are firing after inhibition. On return, - // the y array will be filled in with the cell indices of the cells that are - // firing after inhibition. The number of firing cells placed into the - // y array is given by the return value. - // - // Parameters: - // x: array of cell firing strengths - // y: space to hold output cell indices - // stimulus_threshold: Any cell with an overlap of less than - // stimulusThreshold is not allowed to win - // add_to_winners: Typically a very small number (like .00001) - // that gets added to the firing strength - // of each cell that wins as we go along. This - // prevents us from returning more than the - // desired density of cells when many cells - // are firing with the exact same strength. - template - inline size_type compute(It1 x, It2 y, value_type stimulus_threshold =0, - value_type add_to_winners =0) - { - // This holds the total number of active cells firing after inhibition - size_type n_active = 0; - - if (inhibition_radius >= c_field_size - 1) { // optimized special case - static std::vector vectIndices; - vectIndices.clear(); // purge residual data - - // get the columns with non-trivial values - for (size_type c = 0; c != c_field_size; ++c) { - if (x[c] >= stimulus_threshold) - vectIndices.push_back(c); - } - - // sort the qualified columns in descending value order -#if 0 - // the lambda sort function requires -std=c++0x or -std=gnu++0x, - // first supported in gnu 4.5, but our usage here busts in 4.5.2 - // and may first work in 4.6, not yet available pre-packaged for - // Ubuntu 11.04. - std::sort(vectIndices.begin(), vectIndices.end(), []( size_type a, size_type b) { return x[a] > x[b] ; }) ; -#else - // sort the old-fashioned way - CMySort s(x); - std::sort(vectIndices.begin(), vectIndices.end(), s); -#endif - - // compute how many columns we want - size_type top_n = size_type(0.5 + local_area_density * c_field_size); - if (top_n == 0) - top_n = 1; - - // select the top_n biggest values, less if there aren't enough - if (vectIndices.size() > top_n) - vectIndices.resize(top_n); - std::sort(vectIndices.begin(), vectIndices.end()); // must the returned indices be sorted? - while (n_active < vectIndices.size()) { - y[n_active] = vectIndices[n_active]; - n_active++; - } - - } // optimized special case - else { - - // ------------------------------------------------------------------ - // For every cell in this region.... - for (size_type c = 0; c != c_field_size; ++c) { - - // If the firing strength of this cell is below stimulus threshold, - // it's not allowed to fire - if (x[c] < stimulus_threshold) - continue; - - - // ------------------------------------------------------------------ - // Get the bounds of the inhibition area around this cell - int ch = c / c_width; // The column index of this cell - int cw = c % c_width; // The row index of this cell - - // the index of top of the inhibition area - int lb_height = std::max((int) 0, ch - (int) inhibition_radius); - - // the index of bottom of the inhibition area - int ub_height = std::min(ch + inhibition_radius + 1, c_height); - - // the index of left side of the inhibition area - int lb_width = std::max((int) 0, cw - (int) inhibition_radius); - - // the index of right side of the inhibition area - int ub_width = std::min(cw + inhibition_radius + 1, c_width); - - - // ---------------------------------------------------------------- - // How many cells are allowed to be on within this inhibition area? - // Put that into top_n - size_type top_n = - (size_type) (0.5 + local_area_density - * (ub_height - lb_height) * (ub_width - lb_width)); - if (top_n == 0) - top_n = 1; - - - // ---------------------------------------------------------------- - // Iterate over all other cells within this inhibition area. Keep a count - // of how many are firing STRONGER than this cell. This count goes - // into k. - int k = 0; - for (int px = lb_width; px != ub_width && k < (int) top_n; ++px) - for (int py = lb_height; py != ub_height && k < (int) top_n; ++py) - if (x[(size_type)px + c_width * (size_type)py] > x[c]) - ++k; - - - // ---------------------------------------------------------------- - // If this cell is within the top_n strongest cells, then it is allowed - // to fire. - // - // Take a note of the following example scenario to explain why we need - // add_to_winners: - // 1.) top_n is 10 - // 2.) there are 20 cells in the inhibition area all firing with - // strength 0.8, all other cells are firing less than 0.8 - // 3.) the current cell is firing with strength 0.8. - // - // In this scenario, k will be 0 because no other cells are firing - // stronger than the current cell and we will decide to fire this - // cell. Likewise, for each of the other 20 cells, they will also - // calculate a k of 0 and will also decide to fire. In the end, we - // will end up with 20 firing cells, when the user wanted only 10. - // - // To address this, we add a small factor to each cell's firing strength - // when we decide to fire it. In this way, the first 10 cells that - // we scan with strength 0.8 will get boosted to strength - // 0.8+add_to_winners, and the next 10 will NOT fire because their - // k will be > 10. - // - if (k < (int) top_n) { - y[n_active++] = c; - // add_to_winners prevents us from choosing more than top_n winners - // per inhibition region when more than top_n all have the same - // highest score. - x[c] += add_to_winners; - } - } // for every cell in this region - } // if not the optimized special case - return n_active; - } - }; - - //-------------------------------------------------------------------------------- - //-------------------------------------------------------------------------------- - class FDRCSpatial - { - public: - typedef nupic::UInt32 size_type; - typedef nupic::Real32 value_type; - typedef std::pair IndNZ; - - public: - //-------------------------------------------------------------------------------- - /** - * Constructor for SP. - * - * Creates a random sparse matrix with uniformly distributed non-zeros, all the - * non-zeros having value 1, unless _clone is true, in which case the coincidence - * matrix is not set here, but can be set later from a SM with set_cm. - * The coincidences are sparse 0/1 vectors (vertices of the unit hypercube of - * dimension input_width). - * - * Parameters: - * ========== - * - nbabies: the number of babies in this FDR SP - * _ c_height, c_width: the shape of the coincidence array - * - nrows: the number of coincidence vectors - * - input_width: the size of each coincidence vector (number of elements) - * - nnzpr: number of non-zeros per row, i.e. number of non-zeros in each - * binary coincidence - * - density: number of non-zeros in result vector for infer() ( <= nrows) - * - stimulus_threshold: minimum number of bits in the input that need to - * match with one coincidence for the input vector. If that threshold - * is not met by a pair (coincidence,input), the output for that - * coincidence is zero - * - sparsity_algo: which sparsity enforcing algo to use: globalMax or cellSweeper - * - desired_density: how many non-zeros should each output contain - * - clone: whether to clone this spatial pooler or not. Two or more spatial - * poolers that are cloned share the same coincidences. - * - coincidence_type: the type of coincidence to use. The type determines - * the distribution of the non-zeros inside the coincidence. - * Available types: uniform, gaussian. If gaussian, specify rf_x - * and sigma. - * - rf_x: length of the receptive field in each coincidence in gaussian - * mode: > 0, input_width % rf_x == 0. - * - sigma: sigma for the gaussian distribution when using gaussian - * coincidences, > 0. - * - seed: random seed, that can be set to make runs repeatable. This seed - * influences only the initial random coincidence matrix. There is - * no randomness in the rest of the algorithm. - * - init_nz_val: initial value of the counts for each bit of each coincidence - * (used in learning) - * - threshold_cte: determines histogram threshold, that is, bit count that - * that needs to be exceeded for coincidence bit to participate - * in matching (see learning) - * - normalization_sum: value to which the sum of the bit counts for each - * coincidence is normalized to (reduces the likelihood of a - * coincidence bit to participate in further matching, see learning) - * - normalization_freq: how often normalization is performed - * - hysteresis: Must be >= 1.0. == 1.0 by default. If > 1.0, then outputs that - * were present in the sparse output of the previous time step will - * have their values multiplied by hysteresis before choosing the - * winners in the current time step. - * - * NOTE: - * FDRSpatial starts with learning off. - * - * IMPLEMENTATION NOTE: - * Don't forget to initialize ub to nnzpr for each row, so that we multiply - * correctly in infer when not using learning. - */ - FDRCSpatial(size_type _input_height, size_type _input_width, - size_type _c_height, size_type _c_width, - size_type _c_rf_radius, size_type _c_pool_size, size_type _c_nnz, - value_type _desired_density_learning =.1f, - value_type _desired_density_inference =.1f, - size_type _stimulus_threshold_learning =0, - size_type _stimulus_threshold_inference =1, - value_type _convolution_k_learning =.95f, - value_type _convolution_k_inference =.95f, - int _seed =-1, - value_type _threshold_cte =800.0f, - value_type _normalization_sum =1000.0f, - size_type _clone_height =0, size_type _clone_width =0, - size_type small_threshold_bytes =600*1024*1024) // MB - : rng(_seed == -1 ? rand() : _seed), - input_size(_input_height * _input_width), - input_height(_input_height), input_width(_input_width), - c_height(_c_height), c_width(_c_width), - c_field_size(_c_height * _c_width), - c_rf_radius(_c_rf_radius), - c_pool_size(_c_pool_size), - c_nnz(_c_nnz), - c_rf_side(2*c_rf_radius+1), - c_rf_size(c_rf_side * c_rf_side), - n_masters(_clone_height > 0 ? _clone_height * _clone_width : c_field_size), - clone_height(_clone_height), clone_width(_clone_width), - desired_density_learning(_desired_density_learning), - desired_density_inference(_desired_density_inference), - stimulus_threshold_learning(_stimulus_threshold_learning), - stimulus_threshold_inference(_stimulus_threshold_inference), - convolution_k_learning(_convolution_k_learning), - convolution_k_inference(_convolution_k_inference), - histogram_threshold((value_type) _threshold_cte / (value_type) _c_nnz), - normalization_sum(_normalization_sum), - n_active(0), - small(isCloned() && estimate_max_size_bytes() > small_threshold_bytes), - ind_nz(0), - hists(n_masters * c_pool_size), - cl_map(0), - inv_cl_map(0), - int_buffer(std::max(c_rf_size, c_field_size), 0), - d_output(0), - inhibition(c_height, c_width, desired_density_learning), - yy(getNColumns(), 0), - t_ind() - { - { // Pre-conditions - NTA_ASSERT(!(isCloned() == false && small == true)); - NTA_ASSERT((clone_height == 0 && clone_width == 0) - || clone_height * clone_width != 0); - NTA_ASSERT(c_nnz <= c_pool_size); - NTA_ASSERT(c_pool_size <= (2 * c_rf_radius + 1) * (2 * c_rf_radius + 1)); - NTA_ASSERT(0 < histogram_threshold); - NTA_ASSERT(0 < normalization_sum); - } // End pre-conditions - - initialize_cl_maps(); - initialize_rfs(); - initialize_ind_nz(); // needs rfs and cl_maps - add_val(hists.begin(), hists.end(), 100); - normalize(); - - greater_2nd_p order; - - for (size_type i = 0; i != indNZNRows(); ++i) { - IndNZ *beg = row_begin(i), *end = beg + c_pool_size; - std::partial_sort(beg, beg + c_nnz, end, order); - } - - { // Post-conditions - NTA_ASSERT((small && ind_nz.size() == n_masters * c_pool_size) - || (!small && ind_nz.size() == c_field_size * c_pool_size)); - } // End post-conditions - } - - private: - //-------------------------------------------------------------------------------- - inline void initialize_cl_maps() - { - if (!isCloned()) - return; - - cl_map.resize(c_field_size); - inv_cl_map.resize(getNMasters()); - - for (size_type i = 0; i != getNMasters(); ++i) - inv_cl_map[i].clear(); - - for (size_type i = 0; i != c_field_size; ++i) { - cl_map[i] = clone_width * ((i / c_width) % clone_height) - + (i % c_width) % clone_width; - inv_cl_map[cl_map[i]].push_back(i); - } - - { // Post-conditions - for (size_type i = 0; i != inv_cl_map.size(); ++i) { - NTA_ASSERT(inv_cl_map[i].size() < c_field_size); - for (size_type j = 0; j != inv_cl_map[i].size(); ++j) - NTA_ASSERT(inv_cl_map[i][j] < c_field_size); - } - } - } - - //-------------------------------------------------------------------------------- - inline void initialize_rfs() - { - // compute all receptive fields and store their boundaries - // step is in float, but the rest in double to emulate what numpy - // is doing and get an exact match with Python in unit tests. - double start_height = c_rf_radius; - double stop_height = (input_height - 1) - c_rf_radius + 1; - float step_height = (stop_height - start_height) / double(c_height); - double start_width = c_rf_radius; - double stop_width = (input_width - 1) - c_rf_radius + 1; - float step_width = (stop_width - start_width) / double(c_width); - double fch = start_height; - double fcw = start_width; - - // Could avoid storing this one, except for getMasterLearnedCoincidence, - // used by the inspectors - rfs.resize(4 * c_field_size); - size_type* rfs_p = & rfs[0]; - size_type c_idx = 0; - - for (int i = 0; i != (int) c_height; ++i, fch += step_height) { - fcw = start_width; - for (int j = 0; j != (int) c_width; ++j, fcw += step_width, ++c_idx) { - - NTA_ASSERT(c_idx < c_field_size); - - int ch = (int) fch, cw = (int) fcw; - *rfs_p++ = ch - c_rf_radius; - *rfs_p++ = ch + c_rf_radius + 1; - *rfs_p++ = cw - c_rf_radius; - *rfs_p++ = cw + c_rf_radius + 1; - } - } - } - - //-------------------------------------------------------------------------------- - inline void initialize_ind_nz(size_type* indnz =NULL) - { - ind_nz.resize((small ? n_masters : c_field_size) * c_pool_size); - - std::vector m_ind, perm(c_rf_size); - for (size_type ii = 0; ii != c_rf_size; ++ii) - perm[ii] = ii; - - if (!indnz) { // initialization in constructor - - if (isCloned()) { // cloned initialization, in constructor - - // TODO: get rid of int_buffer? - for (size_type i = 0; i != c_rf_size; ++i) - int_buffer[i] = i; - - m_ind.resize(n_masters * c_pool_size); - - for (size_type i = 0; i != n_masters; ++i) { - std::random_shuffle(perm.begin(), perm.end(), rng); - for (size_type ii = 0; ii != c_pool_size; ++ii) - m_ind[i*c_pool_size + ii] = int_buffer[perm[ii]]; - rand_float_range(hists, i*c_pool_size, (i+1)*c_pool_size, rng); - } - - if (small) { // cloned and small - - size_type k = 0; - for (size_type i = 0; i != n_masters; ++i) - for (size_type ii = 0; ii != c_pool_size; ++ii, ++k) - ind_nz[k] = std::make_pair(m_ind[k], &hists[k]); - - } else { // cloned, not small - - // unroll positions of sampling bits - // grab them here so that the calls to the rng are in the same - // order as Python... - size_type k = 0; - for (size_type c = 0; c != c_field_size; ++c) { - - size_type ii_start = cl_map[c] * c_pool_size; - size_type ii_end = ii_start + c_pool_size; - - for (size_type ii = ii_start; ii != ii_end; ++ii) - ind_nz[k++] = std::make_pair(from_rf(c, m_ind[ii]), &hists[ii]); - } - - } // end clone and not small - - } else { // initialization when not cloning, in constructor - - size_type* rfs_p = &rfs[0]; - for (size_type c = 0; c != c_field_size; ++c) { - - int lb_height = *rfs_p++, ub_height = *rfs_p++; - int lb_width = *rfs_p++, ub_width = *rfs_p++; - - size_type k = 0; - for (int y = lb_height; y != ub_height; ++y) - for (int x = lb_width; x != ub_width; ++x) - int_buffer[k++] = y * input_width + x; - - std::random_shuffle(perm.begin(), perm.end(), rng); - - size_type ii_start = c * c_pool_size; - size_type ii_end = ii_start + c_pool_size; - - for (size_type ii = ii_start; ii != ii_end; ++ii) { - NTA_ASSERT(ii - ii_start < perm.size()); - NTA_ASSERT(perm[ii - ii_start] < int_buffer.size()); - size_type pos_in_input = int_buffer[perm[ii - ii_start]]; - NTA_ASSERT(pos_in_input < input_size); - ind_nz[ii] = std::make_pair(pos_in_input, &hists[ii]); - } - - rand_float_range(hists, ii_start, ii_end, rng); - } - } - - return; - } // end initialization in constructor - - //---------------------------------------- - // Initialization with indnz, in load - //---------------------------------------- - - if (isCloned()) { // cloned - - size_type k = 0; - - for (size_type c = 0; c != indNZNRows(); ++c) { - - size_type ii_start = (!small ? cl_map[c] : c) * c_pool_size; - size_type ii_end = ii_start + c_pool_size; - - for (size_type ii = ii_start; ii != ii_end; ++ii) { - size_type pos_in_rf = indnz[2*ii]; - size_type pos_in_input = !small ? from_rf(c, pos_in_rf) : pos_in_rf; - value_type* ptr = &hists[0] + indnz[2*ii+1]; - ind_nz[k++] = std::make_pair(pos_in_input, ptr); - } - } - - } else { // initialization when not cloning, in load - - for (size_type c = 0; c != c_field_size; ++c) { - - size_type ii_start = c * c_pool_size; - size_type ii_end = ii_start + c_pool_size; - - for (size_type ii = ii_start; ii != ii_end; ++ii) - ind_nz[ii] = std::make_pair(indnz[2*ii], &hists[0] + indnz[2*ii+1]); - } - } - } - - public: - //-------------------------------------------------------------------------------- - /** - * Null constructor for persistence in Python. - */ - inline FDRCSpatial() {} - - //-------------------------------------------------------------------------------- - inline ~FDRCSpatial() {} - - //-------------------------------------------------------------------------------- - /** - * This version tag is used in persistence. - */ - inline const std::string version() const { return "fdrcsp_2.0"; } - - //-------------------------------------------------------------------------------- - /** - * Various accessors. - */ - inline bool isCloned() const { return clone_height > 0; } - inline size_type getNMasters() const { return n_masters; } - inline size_type getNColumns() const { return c_field_size; } - inline size_type getInputSize() const { return input_size; } - inline size_type getRFSide() const { return c_rf_side; } - inline size_type getBitPoolSizePerCoincidence() const { return c_pool_size; } - inline size_type getNSamplingBitsPerCoincidence() const { return c_nnz; } - inline size_type getInhibitionRadius() const - { return inhibition.getInhibitionRadius(); } - inline size_type getStimulusThresholdForLearning() const - { return stimulus_threshold_learning; } - inline size_type getStimulusThresholdForInference() const - { return stimulus_threshold_inference; } - inline value_type getHistogramThreshold() const { return histogram_threshold; } - inline value_type getNormalizationSum() const { return normalization_sum; } - - inline std::pair getInputShape() const - { - return std::make_pair(input_height, input_width); - } - - inline std::pair getCoincidenceFieldShape() const - { - return std::make_pair(c_height, c_width); - } - - inline std::pair getCloningShape() const - { - return std::make_pair(clone_height, clone_width); - } - - //-------------------------------------------------------------------------------- - inline size_t n_bytes() const - { - size_t n = 64 * sizeof(size_type); - n += nupic::n_bytes(ind_nz) + nupic::n_bytes(hists); - n += nupic::n_bytes(cl_map) + nupic::n_bytes(inv_cl_map); - n += inhibition.n_bytes(); - n += nupic::n_bytes(int_buffer); - n += nupic::n_bytes(d_output); - n += nupic::n_bytes(yy); - n += nupic::n_bytes(t_ind); - n += nupic::n_bytes(rfs); - return n; - } - - //-------------------------------------------------------------------------------- - inline bool is_small() const { return small; } - - //-------------------------------------------------------------------------------- - inline void print_size_stats(bool estimate=false) const - { - if (estimate) { - - cout << "Estimated" << endl; - cout << "nc =", c_field_size, endl; - cout << "pool =", c_pool_size, endl; - cout << "ind_nz =", (c_field_size * c_pool_size * sizeof(IndNZ)), endl; - cout << "hists =",(n_masters * c_pool_size * sizeof(value_type)), endl; - cout << "maps =", (2 * c_field_size * sizeof(size_type)), endl; - size_type ir = inhibition.getInhibitionRadius(); - size_type m = (2*ir+1)*(2*ir+1); - cout << "inhib =", (c_field_size * (16 + m * sizeof(size_type))), endl; - cout << "rfs =", (4 * c_field_size * sizeof(size_type)), endl; - - } else { - - size_type n = 64 * sizeof(size_type); - n += nupic::n_bytes(d_output); - n += nupic::n_bytes(yy); - - cout << - " nc =", c_field_size, endl, - "pool =", c_pool_size, endl, - "small =", (small ? "yes" : "no"), endl, - "ind_nz =", nupic::n_bytes(ind_nz), endl, - "hists =", nupic::n_bytes(hists), endl, - "maps =", (nupic::n_bytes(cl_map) + nupic::n_bytes(inv_cl_map)), endl, - "inhib =", inhibition.n_bytes(), endl, - "rfs =", nupic::n_bytes(rfs), endl, - "t_ind =", nupic::n_bytes(t_ind), endl, - "int buffer =", nupic::n_bytes(int_buffer), endl, - "other =", n, endl, - "total =", n_bytes(), endl; - } - } - - //-------------------------------------------------------------------------------- - // TODO: the estimate doesn't seem to be too accurate ?? - // but IndNZ is the quadratic term that leads the asymptote - inline size_type estimate_max_size_bytes() const - { - size_type n = 64 * sizeof(size_type); - n += c_field_size * c_pool_size * sizeof(IndNZ); // ind_nz - n += n_masters * c_pool_size * sizeof(value_type); // hists - n += 2 * c_field_size * sizeof(size_type); // maps - size_type ir = inhibition.getInhibitionRadius(); - size_type m = (2*ir+1)*(2*ir+1); - n += c_field_size * (16 + m * sizeof(size_type)); // inhibition_area - n += 4 * c_field_size * sizeof(size_type); // rfs - n += std::max(c_rf_size, c_field_size) * sizeof(size_type); // int_buffer - n += input_size * c_nnz * sizeof(size_type*); // t_ind - n += input_size * sizeof(size_type); - n += c_field_size * sizeof(size_type); - return n; - } - - //-------------------------------------------------------------------------------- - inline void reset() {} - - //-------------------------------------------------------------------------------- - /** - * For inspectors. - * This makes compute slower. - */ - inline void setStoreDenseOutput(bool x) - { - d_output.resize(x * getNColumns()); - } - - //-------------------------------------------------------------------------------- - /** - * For inspectors, only if setStoreDenseOutput(true) was called before! - */ - template - inline void get_dense_output(It beg) const - { - NTA_ASSERT(!d_output.empty()); - - for (size_type i = 0; i != getNColumns(); ++i) - *beg++ = d_output[i]; - } - - //-------------------------------------------------------------------------------- - /** - * Get the coincidences and histogram counts, either whole, or just the learnt - * part. - * For debugging and testing only, SLOW. - * Doesn't work in nupic2. - */ - inline SparseMatrix - cm(bool withCounts =true, bool learnt =false) const - { - SparseMatrix m(c_field_size, input_size); - - for (size_type i = 0; i != c_field_size; ++i) { - size_type beg = (small ? cl_map[i] : i) * c_pool_size; - size_type end = learnt ? beg + c_nnz : beg + c_pool_size; - for (size_type j = beg; j != end; ++j) { - value_type count = withCounts ? *(ind_nz[j].second) : 1; - size_type pos_in_input = small ? from_rf(i, ind_nz[j].first) : ind_nz[j].first; - m.set(i, pos_in_input, count); - } - } - - return m; - } - - //-------------------------------------------------------------------------------- - /* - * Doesn't work in nupic2. - */ - inline SparseMatrix cm_t() const - { - SparseMatrix m(c_field_size, input_size); - - for (size_type j = 0; j != input_size; ++j) - for (size_type k = 0; k != t_ind[j].size(); ++k) - m.set(t_ind[j][k] - & yy[0], j, 1); - - return m; - } - - //-------------------------------------------------------------------------------- - /** - * Return a single row of the coincidence matrix, as a sparse vector. - * The vector has unsorted indices. - * First requested for inspectors. - */ - template - inline void - get_cm_row_sparse(size_type row, It1 begin_ind, It2 begin_nz, bool learnt =false) const - { - size_type j_start = (small ? cl_map[row] : row) * c_pool_size; - size_type j_end = learnt ? j_start + c_nnz : j_start + c_pool_size; - - for (size_type j = j_start; j != j_end; ++j) { - *begin_ind++ = small ? from_rf(row, ind_nz[j].first) : ind_nz[j].first; - *begin_nz++ = *(ind_nz[j].second); - } - } - - //-------------------------------------------------------------------------------- - template - inline void getMasterLearnedCoincidence(size_type m, It1 rows, It2 cols) - { - NTA_ASSERT(m < n_masters); - - size_type c = (isCloned() && !small) ? inv_cl_map[m][0] : m; - const IndNZ* p = row_begin(c); - - if (!small) - for (size_type i = 0; i != c_nnz; ++i) - to_rf(c, p[i].first, cols[i], rows[i]); - else - for (size_type i = 0; i != c_nnz; ++i) { - cols[i] = p[i].first % c_rf_side; - rows[i] = p[i].first / c_rf_side; - } - } - - //-------------------------------------------------------------------------------- - template - inline void getMasterHistogram(size_type m, It1 rows, It1 cols, It2 values) - { - NTA_ASSERT(m < n_masters); - - size_type c = (isCloned() && !small) ? inv_cl_map[m][0] : m; - const IndNZ* p = row_begin(c); - - if (!small) - for (size_type i = 0; i != c_pool_size; ++i) { - to_rf(c, p[i].first, cols[i], rows[i]); - values[i] = *p[i].second; - } - else - for (size_type i = 0; i != c_pool_size; ++i) { - cols[i] = p[i].first % c_rf_side; - rows[i] = p[i].first / c_rf_side; - values[i] = *p[i].second; - } - } - - //-------------------------------------------------------------------------------- - private: - /** - * Assumes active coincidences are listed in int_buffer. Doesn't modify int_buffer. - */ - template - inline void learn(It x) - { - greater_2nd_p order; - - // this changes the master histograms repeatedly - if (small) { - - for (size_type i = 0; i != n_active; ++i) { - - size_type c = int_buffer[i]; - IndNZ *beg = row_begin(cl_map[c]); - IndNZ *end = beg + c_pool_size; - - for (IndNZ* p = beg; p != end; ++p) - *(p->second) += x[from_rf(c, p->first)]; - } - - } else { // not small - - for (size_type i = 0; i != n_active; ++i) { - - IndNZ *beg = row_begin(int_buffer[i]); - IndNZ *end = beg + c_pool_size; - - for (IndNZ* p = beg; p != end; ++p) - *(p->second) += x[p->first]; - } - } // end not small case - - // now we can normlize the master histograms that were - // touched, one by one, but each only once! (several - // active coincidences might point to the same master - // histogram) - if (isCloned()) { - - std::set touched_masters; - - if (small) { - - for (size_type i = 0; i != n_active; ++i) { - - // to make sure we don't normalize the same master - // histogram twice - size_type c = int_buffer[i]; - size_type master_index = cl_map[c]; - - if (not_in(master_index, touched_masters)) { - normalizeHistogram(master_index); - touched_masters.insert(master_index); - } - } - - // and resort touched master - set::const_iterator it = touched_masters.begin(); - - for (; it != touched_masters.end(); ++it) { - IndNZ *beg = row_begin(*it); - IndNZ *end = beg + c_pool_size; - std::partial_sort(beg, beg + c_nnz, end, order); - } - - } else { // not small - - for (size_type i = 0; i != n_active; ++i) { - - // to make sure we don't normalize the same master - // histogram twice - size_type master_index = cl_map[int_buffer[i]]; - - if (not_in(master_index, touched_masters)) { - normalizeHistogram(master_index); - touched_masters.insert(master_index); - } - } - - // finally, resort all the touched coincidences - // This step can re-order coincidences that were not touched, because - // they share a master with a coincidence that was touched! - std::vector prev(c_pool_size); - set::const_iterator it = touched_masters.begin(); - - for (; it != touched_masters.end(); ++it) { - - const std::vector& clones = inv_cl_map[*it]; - IndNZ *beg = row_begin(clones[0]), *end = beg + c_pool_size; - - std::copy(beg, end, prev.begin()); - - std::partial_sort(beg, beg + c_nnz, end, order); - - std::vector a, b; - - for (size_type i = 0; i != c_nnz; ++i) { - size_type idx = prev[i].first; - bool changed_side = true; - for (size_type j = 0; j != c_nnz; ++j) - if (beg[j].first == idx) { - changed_side = false; - break; - } - if (changed_side) { - a.push_back(i); - } - } - - for (size_type i = c_nnz; i != c_pool_size; ++i) { - size_type idx = prev[i].first; - bool changed_side = false; - for (size_type j = 0; j != c_nnz; ++j) - if (beg[j].first == idx) { - changed_side = true; - break; - } - if (changed_side) { - b.push_back(i); - } - } - - std::copy(prev.begin(), prev.end(), beg); - - if (!a.empty()) { - for (size_type j = 0; j != clones.size(); ++j) { - IndNZ *beg = row_begin(clones[j]); - for (size_type k = 0; k != a.size(); ++k) - std::swap(beg[a[k]], beg[b[k]]); - } - } - } - } - - } else { - - for (size_type i = 0; i != n_active; ++i) { - - size_type active = int_buffer[i]; - normalizeHistogram(active); - - IndNZ *beg = row_begin(active), *end = beg + c_pool_size; - std::partial_sort(beg, beg + c_nnz, end, order); - } - } - } - - //-------------------------------------------------------------------------------- - /** - * The infer() method takes input vectors and produces output vectors that best - * "represent" the input w.r.t. to the matrix of coincidences. The input, output - * and coincidences are all sparse binary (0/1) vectors. The non-zeros of the output - * correspond to the coincidences that best match the input vector. The output - * always has constant sparsity (constant number of non-zeros = density), - * according to FDR principles. The infer method has 2 parts, and optionally - * calls update() to update the coincidences (if learning is on). - * - * This method takes in the input vector x and produces the result vector y which - * the output of the SP itself. The input is a binary 0/1 vector of size input_width - * (the size of the coincidences), and the output is another binary 0/1 vector, - * of size input_height (the number of coincidences). - * - * 1. Compute matches: - * ================== - * This step computes the number of overlapping bits between the input and each - * coincidence. This is achieved as follows: - * Multiply current sparse matrix (in ind_nz) by x on the right, place result into - * y. When doing that multiplication, for row i, we multiply up to ub[i] non-zeros - * only: if we are not doing learning, ub[i] == c_nnz (set in constructor) ; if we are - * learning, ub[i] gets adjusted in update() to the number of non-zeros whose values - * are > threshold. The order of the non-zeros doesn't matter here, except maybe to - * optimize cache usage (try sorting them in increasing order before ub[i]). While - * performing the right vec prod, we also count the number of matches that are - * greater than stimulus_threshold (n_gt). - * - * 2. Impose constant sparsity on outputs: - * ====================================== - * This step selects the top_n coincidences that best match x (highest number of - * overlapping bits), sets the corresponding bits of y to 1, and the others to - * 0 (inhibition). Before we set the bits of y to 0/1, we trigger learning with - * y's top_n first elements containing the indices of the non-zeros we will set - * in y, if doLearn is true. Finally, in_place_sparse_to_dense_01 expands y in - * place, from a vector of top_n indices to a binary 0/1 vector having 1's at - * the positions of the top_n indices only, and 0's elsewhere. - * - * The update() method maintains the counts of the on bits of each coincidence, if - * learning is turned on: the bits that match with the inputs more are reinforced - * and the others are gradually ignored. The update() method has 3 parts. - * - * This method takes in a vector of the indices of the active coincidences, and - * the input vector (needed to compute the overlap with each coincidence and - * increment the bit counters accordingly). - * - * 1. Increment coincidence bit counts: - * =================================== - * For the active coincidences only, we increment the counts of the bits that match - * between the coincidence and x. This will increase the likelihood that "useful" - * bits get promoted for each coincidence, while the bits that don't match enough - * will be made irrelevant. For the purpose of incrementing the counts, we need to - * consider _all_ the non-zeros of each active coincidence, not only the non-zeros - * up to ub[i], since we want the set of "important" bits to be dynamic: new - * "important" bits can enter the set at any point, depending on the statistics - * of the inputs. - * - * 3. Normalize, infrequently: - * ========================== - * Once in a while, we normalize, which has the effect of pushing some coincidence - * bits below the threshold, making them irrelevant for further inferences. This - * operations is done only infrequently because it takes too much time to be done - * on each input vector. It can be thought of as an "inhibition", the more - * relevant bits "inhibiting" those that don't match the inputs often enough. The - * whole row is normalized, including the bits that are 'less relevant' (after - * ub[i]). We normalize *ALL* rows, so that we also normalize rows that were - * updated in between the points at which we normalize (we normalize only every - * 10 steps, for example, but we we update rows on each iteration). - * - * 2. Segregate nz above/below threshold: - * ===================================== - * We update ub[i] for each active row i by sorting the whole row - * and then finding the new ub[i]. Non-zeros with a count above threshold are - * stored before ub[i], and the others after. Note that to segregate correctly, - * we need to take into account both the non-zeros that are currently *above* - * and *below* threshold: depending on the statistics of the input, those two - * sets can change from iteration to iteration. Which means we need to sort - * and threshold on each iteration, *AFTER* incrementing the counts and normalizing - * them. - * - * Parameters: - * ========== - * - babyIdx: index of the baby that should compute on this call - * - x..x_end: input vector (input to the SP) - * - y..y_end: output vector (output of the SP) - * - doLearn: whether to learn or not - * - doInfer: whether to do inference or not - * - * IMPLEMENTATION NOTES: - * 1. If less than stimulus_threshold bits on in x, no coincidence - * will match properly, so we can return the null vector right - * away. - * - * 2. We use n_gt with two different meanings in this function: first, - * it counts the number of on bits in x. Then we reuse it to mean the - * number of coincidences that match x above stimulus_threshold. - * - * 3. To compute the right vec prod (that computes the overlap between the - * coincidences and the input vector) in 1. (hotspot), the loop "jumps over" - * by increments of two, because the coincidences are stored as vector of - * pair(index,counter value), and we need only the indices here. This is much - * faster than iterating on each pair, and dereferencing with pair.first. - */ - public: - template - inline void compute(It1 x, It1 x_end, It2 y, It2 y_end, - bool doLearn =false, bool doInfer =true) - { - { // Pre-conditions - NTA_ASSERT((size_type)(x_end - x) == getInputSize()); - NTA_ASSERT((size_type)(y_end - y) == getNColumns()); - } // End pre-conditions - - size_type count = 0; - - size_type stimulus_threshold = doLearn ? stimulus_threshold_learning - : stimulus_threshold_inference; - - for (It1 x_it = x; x_it != x_end && count <= stimulus_threshold; ++x_it) - count += *x_it != 0; - - if (count <= stimulus_threshold) { - std::fill(y, y_end, 0); - return; - } - - // use DirectAccess and multicolor board if this is slow, - // to amortize the actual setting to 0 - set_to_zero(yy); - - if (t_ind.empty() && doInfer) { - transpose(); - inhibition.setDesiredOutputDensity(desired_density_inference); - } else if (!t_ind.empty() && doLearn) { - t_ind.resize(0); - inhibition.setDesiredOutputDensity(desired_density_learning); - } - - // TODO: test that indices would be as fast as pointers - // and replace pointers to avoid pointer size issues on 64-bits - // platforms - // TODO: combine transposition and inference, so - // the transpose product works in learning too - // TODO: can we compute on the transpose without computing - // the transpose? - // TODO: have the pointers in the transpose land on y directly - // without indirection - if (t_ind.empty()) { - - if (small) { - - for (size_type i = 0; i != c_field_size; ++i) { - - size_type m = cl_map[i]; - value_type s = 0.0f; - size_type *p = &ind_nz[m * c_pool_size].first; - size_type *p_end = p + P_INC * c_nnz; - - for (; p != p_end; p += P_INC) - s += x[from_rf(i, *p)]; - - yy[i] = s; - } - - } else { // not small, faster - - for (size_type i = 0; i != c_field_size; ++i) { - - // *** HOTSPOT *** ?? - value_type s = 0.0f; - size_type *p = &ind_nz[i * c_pool_size].first; - size_type *p_end = p + P_INC * c_nnz; - - for (; p != p_end; p += P_INC) - s += x[*p]; - - yy[i] = s; - } - } - - } else { - - for (It1 it_x = x; it_x != x_end; ++it_x) { - if (*it_x != 0) { - size_type c = (size_type) (it_x - x); - value_type **j = & t_ind[c][0]; - value_type **j_end = j + t_ind[c].size(); - for (; j != j_end; ++j) - **j += *it_x; - } - } - } - - if (!d_output.empty()) - std::copy(yy.begin(), yy.end(), d_output.begin()); - - // 2. Impose constant output sparsity - // puts results in int_buffer - n_active = inhibition.compute(yy.begin(), &int_buffer[0], - stimulus_threshold, - doLearn ? convolution_k_learning - : convolution_k_inference); - - if (doLearn && 0 < n_active) - // looks at int_buffer, but doesn't modify it - learn(x); - - to_dense_01(n_active, int_buffer, y, y_end); - } - - public: - //-------------------------------------------------------------------------------- - // PERSISTENCE - //-------------------------------------------------------------------------------- - /** - * This methods to pickle/unpickle a FDRCSpatial. - */ - inline size_type persistent_size() const - { - std::stringstream buff; - save(buff); - return buff.str().size(); - } - - //-------------------------------------------------------------------------------- - inline void save(std::ostream& out_stream) const - { - { - NTA_ASSERT(out_stream.good()); - } - - out_stream << version() << ' ' - << (t_ind.empty() ? "0 " : "1 ") - << (int) small << ' ' - << rng << ' ' - << input_height << ' ' << input_width << ' ' - << c_height << ' ' << c_width << ' ' - << c_rf_radius << ' ' << c_pool_size << ' ' << c_nnz << ' ' - << c_rf_side << ' ' << c_rf_size << ' ' - << clone_height << ' ' << clone_width << ' ' - << inhibition.getSmall() << ' ' - << desired_density_learning << ' ' - << desired_density_inference << ' ' - << stimulus_threshold_learning << ' ' - << stimulus_threshold_inference << ' ' - << convolution_k_learning << ' ' - << convolution_k_inference << ' ' - << histogram_threshold << ' ' - << normalization_sum << ' ' - << hists << ' ' - << n_active << ' ' - << d_output.size() << ' '; - - size_type n = isCloned() ? n_masters : c_field_size; - - for (size_type i = 0; i != n; ++i) { - - size_type c = (isCloned() && !small) ? inv_cl_map[i][0] : i; - const IndNZ* p = row_begin(c); - - for (size_type j = 0; j != c_pool_size; ++j) { - - size_type pos_in_input = p[j].first; - size_type pos_in_rf = pos_in_input; - - if (isCloned() && !small) - to_rf(c, pos_in_input, pos_in_rf); - - out_stream << pos_in_rf << " " - << (p[j].second - &hists[0]) - << " "; - } - } - } - - //-------------------------------------------------------------------------------- - inline void load(std::istream& in_stream) - { - { - NTA_ASSERT(in_stream.good()); - } - - std::string ver; - in_stream >> ver; - - if (ver != version()) { - std::cout << "Incompatible version for fdr c sp: " << ver - << " - needs: " << version() << std::endl; - exit(-1); - } - - int dos = 0; - int learn_infer_flag = 0; - int is_small = 0; - int small_inhibition = 0; - - in_stream >> learn_infer_flag >> is_small >> rng - >> input_height >> input_width - >> c_height >> c_width - >> c_rf_radius >> c_pool_size >> c_nnz - >> c_rf_side >> c_rf_size - >> clone_height >> clone_width - >> small_inhibition - >> desired_density_learning - >> desired_density_inference - >> stimulus_threshold_learning - >> stimulus_threshold_inference - >> convolution_k_learning - >> convolution_k_inference - >> histogram_threshold - >> normalization_sum - >> hists - >> n_active - >> dos; - - NTA_ASSERT(is_small == 0 || is_small == 1); - small = (bool) is_small; - input_size = input_height * input_width; - c_field_size = c_height * c_width; - n_masters = clone_height > 0 ? clone_height * clone_width : c_field_size; - int_buffer.resize(std::max(c_field_size, c_rf_size), 0); - - std::vector indnz; - size_type n = isCloned() ? n_masters : c_field_size; - indnz.resize(2 * n * c_pool_size); - - for (size_type i = 0; i != indnz.size(); ++i) - in_stream >> indnz[i]; - - initialize_cl_maps(); - initialize_rfs(); - initialize_ind_nz(&indnz[0]); // needs rfs and cl_maps - inhibition.initialize(c_height, c_width, - learn_infer_flag == 0 ? desired_density_learning - : desired_density_inference, small_inhibition); - - d_output.resize(dos); - - yy.resize(getNColumns()); - if (learn_infer_flag == 1) - transpose(); - - { // Post-conditions - NTA_ASSERT(!(isCloned() == false && small == true)); - NTA_ASSERT((clone_height == 0 && clone_width == 0) - || clone_height * clone_width != 0); - NTA_ASSERT((small && ind_nz.size() == n_masters * c_pool_size) - || (!small && ind_nz.size() == c_field_size * c_pool_size)); - NTA_ASSERT(c_nnz <= c_pool_size); - NTA_ASSERT(c_pool_size <= (2 * c_rf_radius + 1) * (2 * c_rf_radius + 1)); - NTA_ASSERT(0 < histogram_threshold); - NTA_ASSERT(0 < normalization_sum); - } // End post-conditions - } - - private: - //-------------------------------------------------------------------------------- - // If small, ind_nz stores only masters, otherwise it stores the full coincidences. - inline size_type indNZNRows() const - { - return small ? n_masters : c_field_size; - } - - //-------------------------------------------------------------------------------- - /** - * Returns a pointer to the first (index,value) pair of row i. - */ - inline IndNZ* row_begin(size_type i) - { - return &ind_nz[0] + i * c_pool_size; - } - - //-------------------------------------------------------------------------------- - /** - * Returns a pointer to the first (index,value) pair of row i. - */ - inline const IndNZ* row_begin(size_type i) const - { - return &ind_nz[0] + i * c_pool_size; - } - - //-------------------------------------------------------------------------------- - /** KEEP: if not storing the clone map, this will give the master index for - any coincidence index - */ - inline size_type getMasterIndex(size_type row_index) const - { - return (row_begin(row_index)->second - &hists[0]) / c_pool_size; - } - - //-------------------------------------------------------------------------------- - inline void - to_rf(size_type c, size_type pos_in_input, - size_type& x_in_rf, size_type& y_in_rf, size_type& pos_in_rf) const - { - NTA_ASSERT(c < c_field_size); - NTA_ASSERT(pos_in_input < input_size); - - size_type lb_height = rfs[4*c]; - size_type lb_width = rfs[4*c+2]; - size_type x_in_input = pos_in_input % input_width; - size_type y_in_input = pos_in_input / input_width; - x_in_rf = x_in_input - lb_width; - y_in_rf = y_in_input - lb_height; - pos_in_rf = y_in_rf * c_rf_side + x_in_rf; - - NTA_ASSERT(x_in_rf < c_rf_side); - NTA_ASSERT(y_in_rf < c_rf_side); - NTA_ASSERT(pos_in_rf < c_rf_size); - } - - //-------------------------------------------------------------------------------- - inline void - to_rf(size_type c, size_type pos_in_input, size_type& pos_in_rf) const - { - size_type x_in_rf = 0, y_in_rf = 0; - to_rf(c, pos_in_input, x_in_rf, y_in_rf, pos_in_rf); - } - - //-------------------------------------------------------------------------------- - inline void - to_rf(size_type c, size_type pos_in_input, size_type& x_in_rf, size_type& y_in_rf) const - { - size_type pos_in_rf = 0; - to_rf(c, pos_in_input, x_in_rf, y_in_rf, pos_in_rf); - } - - //-------------------------------------------------------------------------------- - inline void - from_rf(size_type c, size_type pos_in_rf, - size_type& x_in_input, size_type& y_in_input, size_type& pos_in_input) const - { - NTA_ASSERT(c < c_field_size); - NTA_ASSERT(pos_in_rf < c_rf_size); - - size_type lb_height = rfs[4*c]; - size_type lb_width = rfs[4*c+2]; - size_type x_in_rf = pos_in_rf % c_rf_side; - size_type y_in_rf = pos_in_rf / c_rf_side; - x_in_input = x_in_rf + lb_width; - y_in_input = y_in_rf + lb_height; - pos_in_input = y_in_input * input_width + x_in_input; - - NTA_ASSERT(x_in_input < input_width); - NTA_ASSERT(y_in_input < input_height); - NTA_ASSERT(pos_in_input < input_size); - } - - //-------------------------------------------------------------------------------- - inline size_type from_rf(size_type c, size_type pos_in_rf) const - { - size_type x, y, pos_in_input; - from_rf(c, pos_in_rf, x, y, pos_in_input); - return pos_in_input; - } - - //-------------------------------------------------------------------------------- - /** - * Normalize one histogram. - */ - inline void normalizeHistogram(size_type i) - { - { - NTA_ASSERT((isCloned() && i < getNMasters()) || i < getNColumns()); - } - - value_type* beg = &hists[0] + i * c_pool_size; - value_type* end = beg + c_pool_size; - value_type s = 1e-9f; - - for (value_type *p = beg; p != end; ++p) - s += *p; - - value_type k = normalization_sum / s; - - for (value_type* p = beg; p != end; ++p) - *p *= k; - } - - //-------------------------------------------------------------------------------- - /** - * Normalize all the histograms. - */ - inline void normalize() - { - size_t n = isCloned() ? getNMasters() : getNColumns(); - - for (size_type i = 0; i != n; ++i) - normalizeHistogram(i); - } - - //-------------------------------------------------------------------------------- - inline void transpose() - { - // TODO: maintain the transpose incrementally when doing the swaps - // TODO: transpose only up to first c_nnz positions, or keep - // whole transpose so we can use it in learning too?? - // TODO: interleave t_start and t_nnz for improved locality? - // TODO: reduce type size to fit better in cache - // TODO: speed-up by allocating columns in dense?? - // TODO: remove either t_start or t_nnzc, set up more pointers - // for inference - - // if small, change sizes - t_ind.resize(getInputSize()); - - for (size_type i = 0; i != t_ind.size(); ++i) - t_ind[i].clear(); - - for (size_type i = 0; i != c_field_size; ++i) { - size_type j = (small ? cl_map[i] : i) * c_pool_size; - size_type j_end = j + c_nnz; - for (; j != j_end; ++j) { - size_type pos_in_input = - small ? from_rf(i, ind_nz[j].first) : ind_nz[j].first; - t_ind[pos_in_input].push_back(& yy[0] + i); - } - } - } - - //-------------------------------------------------------------------------------- - nupic::Random rng; - - size_type input_size, input_height, input_width; - size_type c_height, c_width, c_field_size, c_rf_radius, c_pool_size, c_nnz; - size_type c_rf_side, c_rf_size; - size_type n_masters, clone_height, clone_width; - value_type desired_density_learning; - value_type desired_density_inference; - size_type stimulus_threshold_learning; - size_type stimulus_threshold_inference; - value_type convolution_k_learning; - value_type convolution_k_inference; - value_type histogram_threshold; - value_type normalization_sum; - - size_type n_active; - bool small; - std::vector ind_nz; // vectors of pairs - std::vector hists; - std::vector cl_map; - std::vector > inv_cl_map; - std::vector int_buffer; - std::vector d_output; - Inhibition inhibition; - - std::vector yy; - std::vector > t_ind; - - std::vector rfs; - }; - - //-------------------------------------------------------------------------------- - } // end namespace algorithms -} // end namespace nupic - -#endif // NTA_FDR_C_SPATIAL_HPP diff --git a/src/nupic/algorithms/FDRSpatial.hpp b/src/nupic/algorithms/FDRSpatial.hpp deleted file mode 100644 index 4e102657cd..0000000000 --- a/src/nupic/algorithms/FDRSpatial.hpp +++ /dev/null @@ -1,1000 +0,0 @@ -/* --------------------------------------------------------------------- - * Numenta Platform for Intelligent Computing (NuPIC) - * Copyright (C) 2013, Numenta, Inc. Unless you have an agreement - * with Numenta, Inc., for a separate license for this software code, the - * following terms and conditions apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 3 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses. - * - * http://numenta.org/licenses/ - * --------------------------------------------------------------------- - */ - -#ifndef NTA_FDR_SPATIAL_HPP -#define NTA_FDR_SPATIAL_HPP - -#include - -namespace nupic { - namespace algorithms { - - //-------------------------------------------------------------------------------- - /** - * The sweeping algorithm of the continuous spatial pooler. - */ - template - inline void csp_sweep(I c_field_x, I c_field_y, - I stimulusThreshold, - I inhibitionRadius, - It denseOutput, It denseOutput_end, - std::vector& activeElements, - It afterInhibition, It afterInhibition_end) - { - NTA_ASSERT(denseOutput <= denseOutput_end); - - const I n_c = c_field_x * c_field_y; - typedef greater_2nd_no_ties Order; - std::set, Order> to_visit; - std::vector > visited(n_c, std::make_pair(-1,-1)); - - std::fill(afterInhibition, afterInhibition_end, (nupic::Real32)0); - - for (I i = 0; i != n_c; ++i) - if (denseOutput[i] > stimulusThreshold) { - to_visit.insert(std::make_pair(i, denseOutput[i])); - visited[i] = std::make_pair(i, denseOutput[i]); - } - - activeElements.clear(); - - while (! to_visit.empty()) { - - I chosen = to_visit.begin()->first; - activeElements.push_back(chosen); - - I cx = chosen / c_field_y; - I cy = chosen % c_field_y; - I xmin = (I) std::max((int)0, (int)cx - (int)inhibitionRadius); - I xmax = std::min(cx + inhibitionRadius+1, c_field_x); - I ymin = (I) std::max((int)0, (int)cy - (int)inhibitionRadius); - I ymax = std::min(cy + inhibitionRadius+1, c_field_y); - - //std::cout << "Chose: " << chosen - // << " with val: " << to_visit.begin()->second - //<< " at " << cx << "," << cy - // << std::endl; - //std::cout << "xmin= " << xmin << " xmax= " << xmax - // << " ymin= " << ymin << " ymax= " << ymax - // << std::endl; - - //std::cout << "inhibiting: "; - - for (I x = xmin; x != xmax; ++x) - for (I y = ymin; y != ymax; ++y) { - I ii = x * c_field_y + y; - if (visited[ii].first != -1) { - //std::cout << "(" << x << "," << y << "," << ii << ")"; - to_visit.erase(visited[ii]); - visited[ii].first = -1; - } - } - //std::cout << std::endl; - - afterInhibition[chosen] = 1; - } - } - - //-------------------------------------------------------------------------------- - /** - * The FDRSpatial class stores binary 0/1 coincidences and computes the degree - * of match between an input vector (binary 0/1) and each coincidence, to output - * a sparse (binary 0/1) "representation" of the input vector in terms of the - * coincidences. The degree of match is simply the number of bits that overlap - * between each coincidence and the input vector. Only the top-N best matches are - * turned on in the output, and the outputs always have the same, fixed number - * of bits turned on (N), according to FDR principles. - * - * The coincidences can be learnt, in which case the non-zeros of the coincidences - * that match the inputs best are reinforced while others are gradually forgotten. - * Learning is online and the coincidences can adapt to the changing statistics - * of the inputs. - * - * NOTE: - * there are two thresholds used in this class: - * - stimulus_threshold is used to decide whether a coincidence matches the - * input vector well enough or not. It is a hurdle that the coincidence has - * to pass in order to participate in the representation of the input, removing - * coincidences that would have only an insignificant number of bits matching - * the input. - * - histogram_threshold is used, with learning only, to decide which bits from - * the coincidences are more important and can participate in matching the - * input. Bits with a count lower than histogram_threshold are kept in the - * coincidence, but they do not participate to match the input. - * - * IMPLEMENTATION NOTE: - * Each row (coincidence) has exactly nnzpr non-zeros. - * The non-zeros are represented by pairs (index,count) of type (uint,float), - * and we call that type 'IndNZ'. Since all the rows have the same number of - * non-zeros, we use a compact storage where all the non-zeros are stored in - * a vector (of immutable size = nrows * nnzpr), and this vector is called - * 'ind_nz'. The k-th non-zero of row i is at position: ind_nz[i*nnzpr+k]. - * - * IMPLEMENTATION NOTE: - * In order to optimize speed, the non-zeros of each coincidence are stored in - * such a way that the non-zeros which have a count > histogram_threshold appear - * first, and the others after. The boundary between those two sets is maintained - * in ub[i] for each row i. These two sets are updated in update(). In infer(), - * only the non-zeros up to ub[i] are used to compute the match of coincidence i - * and the input vector. - * - * TODOS: - * ===== - * 1. Separate learning from inference (don't call update in infer), which is cleaner - * and we can call infer() without conditionally calling learn(). - * - * 2. Return only indices of the non-zeros from infer(), when integrating with FDR TP. - */ - class FDRSpatial - { - public: - typedef nupic::UInt32 size_type; - typedef nupic::Real32 value_type; - typedef std::pair IndNZ; - - typedef enum { uniform, gaussian } CoincidenceType; - - //-------------------------------------------------------------------------------- - /** - * Constructor for "discrete" SP. - * - * Creates a random sparse matrix with uniformly distributed non-zeros, all the - * non-zeros having value 1, unless _clone is true, in which case the coincidence - * matrix is not set here, but can be set later from a SM with set_cm. - * The coincidences are sparse 0/1 vectors (vertices of the unit hypercube of - * dimension ncols). - * - * Parameters: - * ========== - * - nbabies: the number of babies in this FDR SP - * - nrows: the number of coincidence vectors - * - ncols: the size of each coincidence vector (number of elements) - * - nnzpr: number of non-zeros per row, i.e. number of non-zeros in each - * binary coincidence - * - output_nnz: number of non-zeros in result vector for infer() ( <= nrows) - * - stimulus_threshold: minimum number of bits in the input that need to - * match with one coincidence for the input vector. If that threshold - * is not met by a pair (coincidence,input), the output for that - * coincidence is zero. - * - clone: whether to clone this spatial pooler or not. Two or more spatial - * poolers that are cloned share the same coincidences. - * - coincidence_type: the type of coincidence to use. The type determines - * the distribution of the non-zeros inside the coincidence. - * Available types: uniform, gaussian. If gaussian, specify rf_x - * and sigma. - * - rf_x: length of the receptive field in each coincidence in gaussian - * mode: > 0, ncols % rf_x == 0. - * - sigma: sigma for the gaussian distribution when using gaussian - * coincidences, > 0. - * - seed: random seed, that can be set to make runs repeatable. This seed - * influences only the initial random coincidence matrix. There is - * no randomness in the rest of the algorithm. - * - init_nz_val: initial value of the counts for each bit of each coincidence - * (used in learning) - * - threshold_cte: determines histogram threshold, that is, bit count that - * that needs to be exceeded for coincidence bit to participate - * in matching (see learning) - * - normalization_sum: value to which the sum of the bit counts for each - * coincidence is normalized to (reduces the likelihood of a - * coincidence bit to participate in further matching, see learning) - * - normalization_freq: how often normalization is performed - * - hysteresis: Must be >= 1.0. == 1.0 by default. If > 1.0, then outputs that - * were present in the sparse output of the previous time step will - * have their values multiplied by hysteresis before choosing the - * winners in the current time step. - * - * NOTE: - * FDRSpatial starts with learning off. - * - * IMPLEMENTATION NOTE: - * Don't forget to initialize ub to nnzpr for each row, so that we multiply - * correctly in infer when not using learning. - */ - FDRSpatial(size_type _nbabies, - size_type _nrows, size_type _ncols, size_type _nnzpr, - size_type _output_nnz, - size_type _stimulus_threshold, - bool _clone =false, - CoincidenceType coincidence_type =uniform, - size_type _rf_x =0, - value_type _sigma =0.0f, - int _seed =-1, - value_type _init_nz_val =1.0f, - value_type _threshold_cte =800.0f, - value_type _normalization_sum =1000.0f, - size_type _normalization_freq =20, - value_type _hysteresis =1.0f) - : nbabies(_nbabies), - nrows(_nrows), ncols(_ncols), nnzpr(_nnzpr), iter(0), - output_nnz(_output_nnz), - hysteresis(_hysteresis), - stimulus_threshold(_stimulus_threshold), - histogram_threshold((value_type) _threshold_cte / (value_type) nnzpr), - normalization_sum(_normalization_sum), - normalization_freq(_normalization_freq), - ub(nrows, nnzpr), ind_nz(nrows * nnzpr), - n_prev_winners(0), prev_winners(nrows, 0), - d_output(0) - { - { // Pre-conditions - NTA_ASSERT(0 < nnzpr && nnzpr <= ncols); - NTA_ASSERT(output_nnz <= nrows); - NTA_ASSERT(1.0 <= hysteresis); - NTA_ASSERT(0 < histogram_threshold); - NTA_ASSERT(0 < normalization_sum); - NTA_ASSERT(0 < normalization_freq); - NTA_ASSERT(ub.size() == nrows); - for (size_type i = 0; i != ub.size(); ++i) - NTA_ASSERT(ub[i] == nnzpr); - NTA_ASSERT(coincidence_type == uniform - || coincidence_type == gaussian); - NTA_ASSERT(coincidence_type != gaussian - || (_rf_x > 0 && _sigma > 0)); - } // End pre-conditions - - if (! _clone) { - - if (coincidence_type == uniform) - - random_pair_sample(nrows, ncols, nnzpr, ind_nz, _init_nz_val, _seed); - - else if (coincidence_type == gaussian) - - gaussian_2d_pair_sample(nrows, ncols, nnzpr, _rf_x, _sigma, ind_nz, - _init_nz_val, _seed); - - else { - std::cout << "Unknown coincidence type: " << coincidence_type - << " - exiting" << std::endl; - exit(-1); - } - - normalize(); - } - - { // Post-conditions - NTA_ASSERT(ind_nz.empty() || ind_nz.size() == nrows * nnzpr); - for (size_type i = 0; i != ind_nz.size(); ++i) - NTA_ASSERT(ind_nz[i].first < ncols); - } // End post-conditions - } - - //-------------------------------------------------------------------------------- - /** - * Null constructor for persistence in Python. - */ - inline FDRSpatial() {} - - //-------------------------------------------------------------------------------- - /** - * This version tag is used in persistence. - */ - inline const std::string version() const { return "fdrsp_1.0"; } - - //-------------------------------------------------------------------------------- - /** - * Various accessors. - */ - inline size_type nBabies() const { return nbabies; } - inline size_type nRows() const { return nrows; } - inline size_type nCols() const { return ncols; } - inline size_type nNonZerosPerRow() const { return nnzpr; } - inline size_type nNonZeros() const { return nnzpr * nrows; } - inline size_type nNonZerosInOutput() const { return output_nnz; } - inline value_type getHysteresis() const { return hysteresis; } - inline value_type getStimulusThreshold() const { return stimulus_threshold; } - inline value_type getHistogramThreshold() const { return histogram_threshold; } - inline value_type getNormalizationSum() const { return normalization_sum; } - inline value_type getNormalizationFreq() const { return normalization_freq; } - - //-------------------------------------------------------------------------------- - inline void reset() - { - n_prev_winners = 0; - } - - //-------------------------------------------------------------------------------- - /** - * For inspectors. - * This makes compute slower. - */ - inline void setStoreDenseOutput(bool x) - { - if (x) { - d_output.resize(nbabies); - for (size_type i = 0; i != nbabies; ++i) - d_output[i].resize(nrows); - } else { - d_output.resize(0); - } - } - - //-------------------------------------------------------------------------------- - /** - * For inspectors, only if setStoreDenseOutput(true) was called before! - */ - inline std::vector getDenseOutput(size_type babyIdx) const - { - NTA_ASSERT(babyIdx < nbabies); - NTA_ASSERT(!d_output.empty()); - - return d_output[babyIdx]; - } - - //-------------------------------------------------------------------------------- - /** - * For debugging. - */ - inline std::vector getPrevWinners() const - { - return - std::vector(prev_winners.begin(), prev_winners.begin() + n_prev_winners); - } - - //-------------------------------------------------------------------------------- - /** - * Mostly for debugging, returns vector of positions of last element on each row - * that has a counter > histogram_threshold. - */ - const std::vector& get_ub() const { return ub; } - - //-------------------------------------------------------------------------------- - /** - * Set our coincidences from a SM in csr format (in Python, create the string with - * toPyString()). Resets dimensions to be dimensions of the SM. Also resets ub[i] - * to nnzpr. Assumes that all the rows in the SM have exactly the same number of - * non-zeros (assert). n_bytes is added by SM toCSR, just after the format tag, - * but we don't need it here: we load it and ignore it. - * - * NOTE: the C++ implementation of FDR SP has a single sparse matrix to store *BOTH* - * coincidences' non-zero indices and coincidences' bit counts! Python maintains - * two separate data structures. - * - * NOTE: watch out! If you use this method, it does reset ub[i] to nnzpr, i.e. - * all the bits of all coincidences will be used for matching. - * - * NOTE: the matrix passed in needs to be already normalized. - */ - inline void set_cm(const std::string& cm_string) - { - { - NTA_ASSERT(!cm_string.empty()); - } - - std::stringstream cm_stream(cm_string); - - std::string tag; - cm_stream >> tag; - if (tag != "csr" && tag != "sm_csr_1.5") { - std::cout << "Unknown format for coincidence matrix: " - << tag << std::endl; - exit(-1); - } - - size_type n_bytes = 0, k = 0, nnz = 0; - - cm_stream >> n_bytes >> nrows >> ncols >> nnz; - - ind_nz.resize(nnz); - ub.resize(nrows); - - for (size_type i = 0; i != nrows; ++i) { - - size_type nnz_this_row = 0; - cm_stream >> nnz_this_row; - - if (i == 0) - nnzpr = nnz_this_row; - else - if (nnz_this_row != nnzpr) { - std::cout << "More non-zeros on row " << i - << " than expected (" << nnzpr << ")" - << std::endl; - exit(-1); - } - - for (size_type j = 0; j != nnzpr; ++j, ++k) { - cm_stream >> ind_nz[k].first >> ind_nz[k].second; - if (ind_nz[k].first >= ncols) { - std::cout << "Column index out of bound: " << ind_nz[k].first - << " for non-zero #" << k - << " on row " << i - << std::endl; - exit(-1); - } - } - - ub[i] = nnzpr; - } - - //normalize(); - - { - NTA_ASSERT(k == nnz); - NTA_ASSERT(ind_nz.size() == nnz); - NTA_ASSERT(ub.size() == nRows()); - } - } - - //-------------------------------------------------------------------------------- - /** - * Sets the coincidence matrix/histogram directly from a dense array. That makes - * the Python code much easier (can set directly from a numpy dense array). - */ - template - inline void set_cm_from_dense(It begin, It end) - { - { - NTA_ASSERT((size_type)(end - begin) == nrows * ncols); - NTA_ASSERT(ind_nz.size() == nrows * nnzpr); - } - - size_type k = 0; - - for (size_type i = 0; i != nrows; ++i) { - for (size_type j = 0; j != ncols; ++j) { - if (begin[i*ncols+j] != 0) - ind_nz[k++] = std::make_pair(j, begin[i*ncols+j]); - } - if (k != (i+1) * nnzpr) { - std::cout << "Wrong number of non-zeros on row " << i - << " - expected: " << nnzpr - << " got: " << k << std::endl; - exit(-1); - } - } - } - - //-------------------------------------------------------------------------------- - /** - * Returns coincidence matrix in csr format. That string can be used to initialize - * a SparseMatrix (with constructor in Python). Duplicating nnzpr at the head of - * each row so that the format is compatible with SM csr. To make this string - * compatible with SM fromCSR, we need to add the byte size of the string right - * after the format tag. - * - * NOTE: slow, because resorts the non-zeros on each row to be compatible with SM. - */ - inline std::string get_cm() const - { - std::stringstream cm_stream1, cm_stream2; - - cm_stream1 << "sm_csr_1.5 "; - cm_stream2 << nrows << ' ' - << ncols << ' ' - << ind_nz.size() << ' '; - - for (size_type i = 0; i != nrows; ++i) { - cm_stream2 << nnzpr << ' '; - std::vector buffer(nnzpr); - std::copy(row_begin(i), row_begin(i) + nnzpr, buffer.begin()); - std::sort(buffer.begin(), buffer.end(), less_1st()); - for (size_type j = 0; j != nnzpr; ++j) - cm_stream2 << buffer[j].first << ' ' << buffer[j].second << ' '; - } - - cm_stream1 << cm_stream2.str().size() << ' ' << cm_stream2.str(); - return cm_stream1.str(); - } - - //-------------------------------------------------------------------------------- - /** - * Returns coincidence matrix in csr format, but only the non-zeros which have - * a bit count greater than histogram_threshold. - */ - inline std::string get_truncated_cm() const - { - std::stringstream cm_stream1, cm_stream2; - - cm_stream1 << "sm_csr_1.5 "; - cm_stream2 << nrows << ' ' - << ncols << ' ' - << ind_nz.size() << ' '; - - for (size_type i = 0; i != nrows; ++i) { - cm_stream2 << ub[i] << ' '; - std::vector buffer(nnzpr); - std::copy(row_begin(i), row_begin(i) + ub[i], buffer.begin()); - std::sort(buffer.begin(), buffer.begin() + ub[i], - less_1st()); - for (size_type j = 0; j != ub[i]; ++j) - cm_stream2 << buffer[j].first << ' ' << buffer[j].second << ' '; - } - - cm_stream1 << cm_stream2.str().size() << ' ' << cm_stream2.str(); - return cm_stream1.str(); - } - - //-------------------------------------------------------------------------------- - /** - * Return a single row of the coincidence matrix, as a dense vector. - * First requested for inspectors. - */ - template - inline void get_cm_row_dense(size_type row, It begin, It end) const - { - { - NTA_ASSERT(row < nrows); - } - - std::fill(begin, end, 0); - - for (size_type i = 0; i != nnzpr; ++i) - *(begin + ind_nz[row*nnzpr + i].first) = ind_nz[row*nnzpr + i].second; - } - - //-------------------------------------------------------------------------------- - template - inline void get_cm_row_sparse(size_type row, It1 begin_ind, It2 begin_nz) const - { - { - NTA_ASSERT(row < nrows); - } - - std::vector buffer(nnzpr); - std::copy(row_begin(row), row_begin(row) + nnzpr, buffer.begin()); - std::sort(buffer.begin(), buffer.begin() + nnzpr, - less_1st()); - for (size_type j = 0; j != nnzpr; ++j) { - *begin_ind++ = buffer[j].first; - *begin_nz++ = buffer[j].second; - } - } - - //-------------------------------------------------------------------------------- - /** - * Returns the amount of overlap (the number of matching bits) between x and - * each coincidence. - * First requested for inspectors. - * - * Call in inference (matches only the _learnt_ bits of the coincidences). - */ - template - inline size_type overlaps(It1 x, It2 y2, It3 y3) - { - size_type n = 0; - - for (size_type i = 0; i != nrows; ++i) { - - if (y2[i] > 0) { - - value_type s = 0.0f; - size_type *p = &ind_nz[i * nnzpr].first, *p_end = p + 2 * ub[i]; - - for (; p != p_end; p += 2) - s += x[*p]; - - *y3++ = s; - ++n; - } - } - - return n; - } - - //-------------------------------------------------------------------------------- - /** - * The update() method maintains the counts of the on bits of each coincidence, if - * learning is turned on: the bits that match with the inputs more are reinforced - * and the others are gradually ignored. The update() method has 3 parts. - * - * This method takes in a vector of the indices of the active coincidences, and - * the input vector (needed to compute the overlap with each coincidence and - * increment the bit counters accordingly). - * - * 1. Increment coincidence bit counts: - * =================================== - * For the active coincidences only, we increment the counts of the bits that match - * between the coincidence and x. This will increase the likelihood that "useful" - * bits get promoted for each coincidence, while the bits that don't match enough - * will be made irrelevant. For the purpose of incrementing the counts, we need to - * consider _all_ the non-zeros of each active coincidence, not only the non-zeros - * up to ub[i], since we want the set of "important" bits to be dynamic: new - * "important" bits can enter the set at any point, depending on the statistics - * of the inputs. - * - * 3. Normalize, infrequently: - * ========================== - * Once in a while, we normalize, which has the effect of pushing some coincidence - * bits below the threshold, making them irrelevant for further inferences. This - * operations is done only infrequently because it takes too much time to be done - * on each input vector. It can be thought of as an "inhibition", the more - * relevant bits "inhibiting" those that don't match the inputs often enough. The - * whole row is normalized, including the bits that are 'less relevant' (after - * ub[i]). We normalize *ALL* rows, so that we also normalize rows that were - * updated in between the points at which we normalize (we normalize only every - * 10 steps, for example, but we we update rows on each iteration). - * - * 2. Segregate nz above/below threshold: - * ===================================== - * We update ub[i] for each active row i by sorting the whole row - * and then finding the new ub[i]. Non-zeros with a count above threshold are - * stored before ub[i], and the others after. Note that to segregate correctly, - * we need to take into account both the non-zeros that are currently *above* - * and *below* threshold: depending on the statistics of the input, those two - * sets can change from iteration to iteration. Which means we need to sort - * and threshold on each iteration, *AFTER* incrementing the counts and normalizing - * them. - * - * Parameters: - * ========== - * - active..active_end: a vector containing the indices of the active - * coincidences (size <= nrows) - * - x..x_end: the input vector (size == ncols) - * - * TODO: maintain ub[i] incrementally instead of sorting each time - * TODO: update only infrequently, and accumulate in the meantime - * TODO: see if it's faster to normalize only the active rows, on each iteration - * TODO: jump by 2 in 1. to avoid dereferencing the pair - */ - private: - template - inline void update(It1 active, It1 active_end, It2 x, It2 x_end) - { - { // Pre-conditions - NTA_ASSERT(active <= active_end); - NTA_ASSERT((size_type)(x_end - x) == ncols); - NTA_ASSERT(0 < normalization_freq); - NTA_ASSERT(0 < histogram_threshold); - NTA_ASSERT(ub.size() == nrows); - NTA_ASSERT(!ind_nz.empty() && ind_nz.size() == nrows * nnzpr); - for (size_type i = 0; i != ind_nz.size(); ++i) - NTA_ASSERT(ind_nz[i].first < ncols); - for (It1 it = active; it != active_end; ++it) - NTA_ASSERT(*it < nrows); - } // End pre-conditions - - // 1. Increment the counts up to nnzpr - for (It1 it = active; it != active_end; ++it) { - - size_type i = (size_type) *it; - IndNZ *p_beg = row_begin(i), *p_end = p_beg + nnzpr; - - for (IndNZ* p = p_beg; p != p_end; ++p) - p->second += x[p->first]; - } - - // 2. Normalize, infrequently - if (iter % normalization_freq == 0) { - - normalize(); - - // 3. Segregate nz above/below threshold (update ub[i]) - for (size_type i = 0; i != nrows; ++i) { - - size_type j = 0; - IndNZ *p_beg = row_begin(i), *p_end = p_beg + nnzpr; - - std::sort(p_beg, p_end, greater_2nd()); - - while (j < nnzpr && p_beg[j].second > histogram_threshold) - ++j; - - ub[i] = j; - } - } - - { // Post-conditions - //for (It1 it = active; it != active_end; ++it) - // NTA_ASSERT(ub[*it] <= nnzpr); - } // End post-conditions - } - - //-------------------------------------------------------------------------------- - /** - * The infer() method takes input vectors and produces output vectors that best - * "represent" the input w.r.t. to the matrix of coincidences. The input, output - * and coincidences are all sparse binary (0/1) vectors. The non-zeros of the output - * correspond to the coincidences that best match the input vector. The output - * always has constant sparsity (constant number of non-zeros = output_nnz), - * according to FDR principles. The infer method has 2 parts, and optionally - * calls update() to update the coincidences (if learning is on). - * - * This method takes in the input vector x and produces the result vector y which - * the output of the SP itself. The input is a binary 0/1 vector of size ncols - * (the size of the coincidences), and the output is another binary 0/1 vector, - * of size nrows (the number of coincidences). - * - * 1. Compute matches: - * ================== - * This step computes the number of overlapping bits between the input and each - * coincidence. This is achieved as follows: - * Multiply current sparse matrix (in ind_nz) by x on the right, place result into - * y. When doing that multiplication, for row i, we multiply up to ub[i] non-zeros - * only: if we are not doing learning, ub[i] == nnzpr (set in constructor) ; if we are - * learning, ub[i] gets adjusted in update() to the number of non-zeros whose values - * are > threshold. The order of the non-zeros doesn't matter here, except maybe to - * optimize cache usage (try sorting them in increasing order before ub[i]). While - * performing the right vec prod, we also count the number of matches that are - * greater than stimulus_threshold (n_gt). - * - * 2. Impose constant sparsity on outputs: - * ====================================== - * This step selects the top_n coincidences that best match x (highest number of - * overlapping bits), sets the corresponding bits of y to 1, and the others to - * 0 (inhibition). Before we set the bits of y to 0/1, we trigger learning with - * y's top_n first elements containing the indices of the non-zeros we will set - * in y, if doLearn is true. Finally, in_place_sparse_to_dense_01 expands y in - * place, from a vector of top_n indices to a binary 0/1 vector having 1's at - * the positions of the top_n indices only, and 0's elsewhere. - * - * Parameters: - * ========== - * - babyIdx: index of the baby that should compute on this call - * - x..x_end: input vector (input to the SP) - * - y..y_end: output vector (output of the SP) - * - doLearn: whether to learn or not - * - doInfer: whether to do inference or not - * - * IMPLEMENTATION NOTES: - * 1. If less than stimulus_threshold bits on in x, no coincidence - * will match properly, so we can return the null vector right - * away. - * - * 2. We use n_gt with two different meanings in this function: first, - * it counts the number of on bits in x. Then we reuse it to mean the - * number of coincidences that match x above stimulus_threshold. - * - * 3. To compute the right vec prod (that computes the overlap between the - * coincidences and the input vector) in 1. (hotspot), the loop "jumps over" - * by increments of two, because the coincidences are stored as vector of - * pair(index,counter value), and we need only the indices here. This is much - * faster than iterating on each pair, and dereferencing with pair.first. - * - * TODO: measure impact of sorted non-zeros before ub[i] on cache - * TODO: return only the indices of the non-zeros in the output, once - * integrated with the FDR TP - * TODO: write faster asm count_non_zeros (the current one uses count_gt) - * TODO: avoid having to resort for in_place_sparse_to_dense_01 (requires - * writing another in_place_sparse_to_dense_01) - */ - public: - template - inline void compute(size_type babyIdx, - It1 x, It1 x_end, It2 y, It2 y_end, - bool doLearn =false, bool doInfer =true) - { - { // Pre-conditions - NTA_ASSERT(babyIdx < nbabies); - NTA_ASSERT((size_type)(x_end - x) == ncols); - NTA_ASSERT((size_type)(y_end - y) == nrows); - NTA_ASSERT(!ind_nz.empty() && ind_nz.size() == nrows * nnzpr); - NTA_ASSERT(ub.size() == nrows); - for (size_type i = 0; i != ub.size(); ++i) - NTA_ASSERT(ub[i] <= nnzpr); - for (size_type i = 0; i != ind_nz.size(); ++i) - NTA_ASSERT(ind_nz[i].first < ncols); - } // End pre-conditions - - // 0. Compute number of on bits in input vector x - size_type n_gt = count_non_zeros(x, x_end); - - if (n_gt <= stimulus_threshold) { - std::fill(y, y_end, 0); - return; - } - - // 1. Compute matches - n_gt = 0; - - for (size_type i = 0; i != nrows; ++i) { - - // *** HOTSPOT *** in r26326 - value_type s = 0.0f; - size_type *p = &ind_nz[i * nnzpr].first, *p_end = p + 2 * ub[i]; - - for (; p != p_end; p += 2) - s += x[*p]; - - y[i] = s; - } - - if (hysteresis > 1.0f) { - size_type *i = &prev_winners[0], *i_end = i + n_prev_winners; - for (; i != i_end; ++i) - y[*i] *= hysteresis; - } - - for (size_type i = 0; i != nrows; ++i) - if (y[i] > stimulus_threshold) - ++n_gt; - - // Only for inspectors, slow, off by default - if (!d_output.empty()) - std::copy(y, y_end, d_output[babyIdx].begin()); - - // 2. Impose constant output sparsity - size_type top_n = std::min(output_nnz, n_gt); - - if (top_n == 0) { - std::fill(y, y_end, 0); - return; - } - - partial_argsort(top_n, y, y_end, y, y_end); - - if (doLearn) - update(y, y + top_n, x, x_end); - - if (hysteresis > 1.0f) { - n_prev_winners = top_n; - std::copy(y, y + top_n, prev_winners.begin()); - } - - // TODO: disconnect this if doInfer is false - // in_place_sparse_to_dense_01 requires sorted indices! - std::sort(y, y + top_n); - in_place_sparse_to_dense_01(top_n, y, y_end); - - ++iter; - } - - //-------------------------------------------------------------------------------- - // PERSISTENCE - //-------------------------------------------------------------------------------- - /** - * This methods to pickle/unpickle a FDRSpatial. - */ - inline size_type persistent_size() const - { - std::stringstream buff; - save(buff); - return buff.str().size(); - } - - //-------------------------------------------------------------------------------- - inline void save(std::ostream& out_stream) const - { - { - NTA_ASSERT(out_stream.good()); - NTA_ASSERT(ind_nz.size() == nrows * nnzpr); - NTA_ASSERT(ub.size() == nRows()); - for (size_type i = 0; i != ind_nz.size(); ++i) - NTA_ASSERT(ind_nz[i].first < ncols); - } - - out_stream << version() << ' ' << nbabies << ' ' - << nrows << ' ' << ncols << ' ' << nnzpr << ' ' - << iter << ' ' - << output_nnz << ' ' - << hysteresis << ' ' - << stimulus_threshold << ' ' - << histogram_threshold << ' ' - << normalization_sum << ' ' - << normalization_freq << ' ' - << ub << ' ' - << ind_nz << ' ' - << n_prev_winners << ' ' - << prev_winners << ' '; - } - - //-------------------------------------------------------------------------------- - inline void load(std::istream& in_stream) - { - { - NTA_ASSERT(in_stream.good()); - } - - std::string ver; - in_stream >> ver; - assert(ver == version()); - - in_stream >> nbabies - >> nrows >> ncols >> nnzpr >> iter - >> output_nnz - >> hysteresis - >> stimulus_threshold - >> histogram_threshold - >> normalization_sum - >> normalization_freq - >> ub - >> ind_nz - >> n_prev_winners - >> prev_winners; - - d_output.resize(0); - - { - NTA_ASSERT(ind_nz.size() == nrows * nnzpr); - NTA_ASSERT(1.0 <= hysteresis); - NTA_ASSERT(0 < histogram_threshold); - NTA_ASSERT(0 < normalization_sum); - NTA_ASSERT(0 < normalization_freq); - NTA_ASSERT(ub.size() == nRows()); - for (size_type i = 0; i != ub.size(); ++i) - NTA_ASSERT(ub[i] <= nnzpr); - for (size_type i = 0; i != ind_nz.size(); ++i) - NTA_ASSERT(ind_nz[i].first < ncols); - } - } - - private: - - //-------------------------------------------------------------------------------- - /** - * Returns a pointer to the first (index,value) pair of row i. - */ - inline IndNZ* row_begin(size_type i) - { - NTA_ASSERT(i < nRows()); - return &ind_nz[0] + i * nnzpr; - } - - //-------------------------------------------------------------------------------- - /** - * Returns a pointer to the first (index,value) pair of row i. - */ - inline const IndNZ* row_begin(size_type i) const - { - NTA_ASSERT(i < nRows()); - return &ind_nz[0] + i * nnzpr; - } - - //-------------------------------------------------------------------------------- - /** - * Normalizes each row of the coincidence matrix separately, so that the sum - * of each column is equal to normalization_sum (set in constructor). - */ - inline void normalize() - { - NTA_ASSERT(0 < normalization_sum); - - for (size_type i = 0; i != nrows; ++i) { - IndNZ* p_beg = row_begin(i), *p_end = p_beg + nnzpr; - value_type s = 0.0f; - for (IndNZ* p = p_beg; p != p_end; ++p) - s += p->second; - if (s == 0.0f) - return; - value_type k = normalization_sum / s; - NTA_ASSERT(k != 0.0f); - for (IndNZ* p = p_beg; p != p_end; ++p) - p->second *= k; - } - } - - //-------------------------------------------------------------------------------- - size_type nbabies; - size_type nrows, ncols, nnzpr; // nnzpr = number of non-zeros per row - size_type iter; // current iteration number - size_type output_nnz; // number of nz desired in output vector - value_type hysteresis; // hysteresis factor - value_type stimulus_threshold; // see infer() - value_type histogram_threshold; // see update() - value_type normalization_sum; // see update() - size_type normalization_freq; // see update() - - std::vector ub; // ub[row] = 1+index of last nz > histogram_threshold - std::vector ind_nz; // vectors of pairs - - size_type n_prev_winners; // for hysteresis, n of prev winners - std::vector prev_winners; // for hysteresis - - // for inspectors only, makes compute slow - std::vector > d_output; - }; - - //-------------------------------------------------------------------------------- - } // end namespace algorithms -} // end namespace nupic - -#endif // NTA_FDR_SPATIAL_HPP From dd6680ae289a00df5942891f8539e2bb9535b89b Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Mon, 2 Mar 2015 12:02:09 +0100 Subject: [PATCH 002/100] SpatialPooler use constructor with params --- src/nupic/algorithms/SpatialPooler.cpp | 41 ++++++++++++++++++++++++++ src/nupic/algorithms/SpatialPooler.hpp | 19 ++++++++++++ 2 files changed, 60 insertions(+) diff --git a/src/nupic/algorithms/SpatialPooler.cpp b/src/nupic/algorithms/SpatialPooler.cpp index a79e1d9d8b..20dd6106ce 100644 --- a/src/nupic/algorithms/SpatialPooler.cpp +++ b/src/nupic/algorithms/SpatialPooler.cpp @@ -118,6 +118,47 @@ SpatialPooler::SpatialPooler() version_ = 2; } +SpatialPooler::SpatialPooler(vector inputDimensions, + vector columnDimensions, + UInt potentialRadius, + Real potentialPct, + bool globalInhibition, + Real localAreaDensity, + UInt numActiveColumnsPerInhArea, + UInt stimulusThreshold, + Real synPermInactiveDec, + Real synPermActiveInc, + Real synPermConnected, + Real minPctOverlapDutyCycles, + Real minPctActiveDutyCycles, + UInt dutyCyclePeriod, + Real maxBoost, + Int seed, + UInt spVerbosity, + bool wrapAround) +{ + SpatialPooler sp; + sp.initialize(inputDimensions, + columnDimensions, + potentialRadius, + potentialPct, + globalInhibition, + localAreaDensity, + numActiveColumnsPerInhArea, + stimulusThreshold, + synPermInactiveDec, + synPermActiveInc, + synPermConnected, + minPctOverlapDutyCycles, + minPctActiveDutyCycles, + dutyCyclePeriod, + maxBoost, + seed, + spVerbosity, + wrapAround); +} + + vector SpatialPooler::getColumnDimensions() const { return columnDimensions_; diff --git a/src/nupic/algorithms/SpatialPooler.hpp b/src/nupic/algorithms/SpatialPooler.hpp index e8ef1b6949..2dd8907632 100644 --- a/src/nupic/algorithms/SpatialPooler.hpp +++ b/src/nupic/algorithms/SpatialPooler.hpp @@ -69,6 +69,25 @@ namespace nupic { class SpatialPooler { public: SpatialPooler(); + SpatialPooler(vector inputDimensions, + vector columnDimensions, + UInt potentialRadius=16, + Real potentialPct=0.5, + bool globalInhibition=true, + Real localAreaDensity=-1.0, + UInt numActiveColumnsPerInhArea=10, + UInt stimulusThreshold=0, + Real synPermInactiveDec=0.01, + Real synPermActiveInc=0.1, + Real synPermConnected=0.1, + Real minPctOverlapDutyCycles=0.001, + Real minPctActiveDutyCycles=0.001, + UInt dutyCyclePeriod=1000, + Real maxBoost=10.0, + Int seed=1, + UInt spVerbosity=0, + bool wrapAround=true); + virtual ~SpatialPooler() {} From 8ca0b8b4e61a7996d8b4c7d36f4700e0ac5ac06e Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Mon, 2 Mar 2015 12:59:12 +0100 Subject: [PATCH 003/100] HelloWorld example for SP --- src/CMakeLists.txt | 17 ++++- src/examples/nupic/algorithms/HelloSP_TP.cpp | 75 ++++++++++++++++++++ 2 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 src/examples/nupic/algorithms/HelloSP_TP.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index aa02219279..db2379aa52 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -456,6 +456,18 @@ set_target_properties(${EXECUTABLE_PROTOTEST} PROPERTIES LINK_FLAGS "${COMMON_LINK_FLAGS}") add_dependencies(${EXECUTABLE_PROTOTEST} ${COMMON_LIBS}) +# TODO better way to build examples? +# +# Setup HelloSP_TP example +# +set(EXECUTABLE_HELLOSPTP hello_sp_tp) +add_executable(${EXECUTABLE_HELLOSPTP} examples/nupic/algorithms/HelloSP_TP.cpp) +target_link_libraries(${EXECUTABLE_HELLOSPTP} ${COMMON_LIBS}) +set_target_properties(${EXECUTABLE_HELLOSPTP} PROPERTIES COMPILE_FLAGS ${COMMON_COMPILE_FLAGS}) +set_target_properties(${EXECUTABLE_HELLOSPTP} PROPERTIES LINK_FLAGS "${COMMON_LINK_FLAGS}") +add_dependencies(${EXECUTABLE_HELLOSPTP} ${COMMON_LIBS}) + + # # Setup gtests # @@ -586,7 +598,8 @@ if(UNIX) ${LIB_STATIC_GTEST} ${EXECUTABLE_HELLOREGION} ${EXECUTABLE_CPPREGIONTEST} - ${EXECUTABLE_GTESTS}) + ${EXECUTABLE_GTESTS} + ${EXECUTABLE_HELLOSPTP}) else() add_custom_target(combined ALL COMMAND lib.exe /OUT:nupic_core.lib @@ -601,6 +614,7 @@ else() ${EXECUTABLE_HELLOREGION} ${EXECUTABLE_CPPREGIONTEST} ${EXECUTABLE_GTESTS} + ${EXECUTABLE_HELLOSPTP} VERBATIM) endif() @@ -613,6 +627,7 @@ install(TARGETS ${EXECUTABLE_HELLOREGION} ${EXECUTABLE_CPPREGIONTEST} ${EXECUTABLE_PYREGIONTEST} + ${EXECUTABLE_HELLOSPTP} ${EXECUTABLE_PROTOTEST} ${EXECUTABLE_GTESTS} RUNTIME DESTINATION bin diff --git a/src/examples/nupic/algorithms/HelloSP_TP.cpp b/src/examples/nupic/algorithms/HelloSP_TP.cpp new file mode 100644 index 0000000000..3bdd32a038 --- /dev/null +++ b/src/examples/nupic/algorithms/HelloSP_TP.cpp @@ -0,0 +1,75 @@ +/* --------------------------------------------------------------------- + * Numenta Platform for Intelligent Computing (NuPIC) + * Copyright (C) 2013-2014, Numenta, Inc. Unless you have an agreement + * with Numenta, Inc., for a separate license for this software code, the + * following terms and conditions apply: + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses. + * + * http://numenta.org/licenses/ + * --------------------------------------------------------------------- + */ + +#include +#include +#include // std::generate +#include // std::time +#include // std::rand, std::srand + +#include "nupic/algorithms/SpatialPooler.hpp" +#include "nupic/algorithms/Cells4.hpp" + +using namespace std; +using namespace nupic; +using namespace nupic::algorithms::spatial_pooler; +using namespace nupic::algorithms::Cells4; + +// function generator: +int RandomNumber01 () { return (rand()%2); } + +int main(int argc, const char * argv[]) +{ +const int DIM = 2048; +const int DIM_INPUT = 10000; + + vector inputDim; + inputDim.push_back(DIM_INPUT); + inputDim.push_back(1); + + vector colDim; + colDim.push_back(DIM); + colDim.push_back(1); + + // generate random input + vector input(DIM_INPUT); + generate(input.begin(), input.end(), RandomNumber01); + vector outSP(DIM); // active array, output of SP/TP + vector outTP(DIM); + +// cout << "input=" << input << endl; + + SpatialPooler sp; //! (inputDim, colDim); + sp.initialize(inputDim, colDim); //! fix to use constructor above + Cells4 tp(DIM); + + //run + fill(outSP.begin(), outSP.end(), 0); + sp.compute(&input[0], true, &outSP[0]); + cout << "SP=" << outSP << endl; + + fill(outTP.begin(), outTP.end(), 0); +//! tp.compute(&input[0], &outTP[0], true, true); + cout << "TP=" << outTP << endl; + + return 0; +} From a347e954baf070318d2576c626e4f26e79ba062a Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Mon, 2 Mar 2015 13:46:46 +0100 Subject: [PATCH 004/100] TP deault constructor same params as py.TP --- src/nupic/algorithms/Cells4.hpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/nupic/algorithms/Cells4.hpp b/src/nupic/algorithms/Cells4.hpp index 9b471b215e..0b247ac2ea 100644 --- a/src/nupic/algorithms/Cells4.hpp +++ b/src/nupic/algorithms/Cells4.hpp @@ -394,11 +394,12 @@ namespace nupic { /** * Default constructor needed when lifting from persistence. */ - Cells4(UInt nColumns =0, UInt nCellsPerCol =0, - UInt activationThreshold =1, - UInt minThreshold =1, - UInt newSynapseCount =1, - UInt segUpdateValidDuration =1, + Cells4(UInt nColumns =500, + UInt nCellsPerCol =10, + UInt activationThreshold =12, + UInt minThreshold =8, + UInt newSynapseCount =15, + UInt segUpdateValidDuration =5, Real permInitial =.5, Real permConnected =.8, Real permMax =1, @@ -406,7 +407,7 @@ namespace nupic { Real permInc =.1, Real globalDecay =0, bool doPooling =false, - int seed =-1, + int seed =42, bool doItAll =false, bool checkSynapseConsistency =false); @@ -416,11 +417,12 @@ namespace nupic { * This also called when lifting from persistence. */ void - initialize(UInt nColumns =0, UInt nCellsPerCol =0, - UInt activationThreshold =1, - UInt minThreshold =1, - UInt newSynapseCount =1, - UInt segUpdateValidDuration =1, + initialize(UInt nColumns =500, + UInt nCellsPerCol =10, + UInt activationThreshold =12, + UInt minThreshold =8, + UInt newSynapseCount =15, + UInt segUpdateValidDuration =5, Real permInitial =.5, Real permConnected =.8, Real permMax =1, From f9f5efbbb815682e36b7ce61be17fbe59cadf06b Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Mon, 2 Mar 2015 14:29:12 +0100 Subject: [PATCH 005/100] c++ TP (Cells4) uses UInt* as input representation --- src/nupic/algorithms/Cells4.cpp | 6 +++--- src/nupic/algorithms/Cells4.hpp | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/nupic/algorithms/Cells4.cpp b/src/nupic/algorithms/Cells4.cpp index a0dc8b2e1e..2adc3b713a 100644 --- a/src/nupic/algorithms/Cells4.cpp +++ b/src/nupic/algorithms/Cells4.cpp @@ -899,7 +899,7 @@ void Cells4::learnPhase2(bool readOnly) * Update the learning state. Called from compute() */ void Cells4::updateLearningState(const std::vector & activeColumns, - Real* input) + UInt* input) { // ========================================================================= // Copy over learning states to t-1 and reset state at t to 0 @@ -1230,7 +1230,7 @@ bool Cells4::inferPhase2() /** * Main compute routine, called for both learning and inference. */ -void Cells4::compute(Real* input, Real* output, bool doInference, bool doLearning) +void Cells4::compute(UInt* input, UInt* output, bool doInference, bool doLearning) { TIMER(computeTimer.start()); NTA_CHECK(doInference || doLearning); @@ -1436,7 +1436,7 @@ void Cells4::_updateAvgLearnedSeqLength(UInt prevSeqLength) /** * Go through the list of accumulated segment updates and process them. */ -void Cells4::processSegmentUpdates(Real* input, const CState& predictedState) +void Cells4::processSegmentUpdates(UInt* input, const CState& predictedState) { static std::vector delUpdates; delUpdates.clear(); // purge residual data diff --git a/src/nupic/algorithms/Cells4.hpp b/src/nupic/algorithms/Cells4.hpp index 0b247ac2ea..2aef9d60fc 100644 --- a/src/nupic/algorithms/Cells4.hpp +++ b/src/nupic/algorithms/Cells4.hpp @@ -356,7 +356,7 @@ namespace nupic { Real* _cellConfidenceCandidate; Real* _colConfidenceCandidate; - Real* _tmpInputBuffer; + UInt* _tmpInputBuffer; #if SOME_STATES_NOT_INDEXED CState _infActiveStateCandidate; CState _infPredictedStateCandidate; @@ -635,7 +635,7 @@ namespace nupic { * doInference: if true, inference output will be computed * doLearning: if true, learning will occur */ - void compute(Real* input, Real* output, bool doInference, bool doLearning); + void compute(UInt* input, UInt* output, bool doInference, bool doLearning); //----------------------------------------------------------------------- /** @@ -771,7 +771,7 @@ namespace nupic { * activeColumns: Indices of active columns */ void updateLearningState(const std::vector & activeColumns, - Real* input); + UInt* input); //----------------------------------------------------------------------- /** @@ -946,7 +946,7 @@ namespace nupic { * cell * */ - void processSegmentUpdates(Real* input, const CState& predictedState); + void processSegmentUpdates(UInt* input, const CState& predictedState); //---------------------------------------------------------------------- /** From 9683f38efd248f1dd25fc3c61ace497e0294ea7c Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Mon, 2 Mar 2015 14:59:25 +0100 Subject: [PATCH 006/100] Revert "c++ TP (Cells4) uses UInt* as input representation" This reverts commit 3b4c7ad7ac23171776b2071c093dc30efc46d6fd. --- src/nupic/algorithms/Cells4.cpp | 6 +++--- src/nupic/algorithms/Cells4.hpp | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/nupic/algorithms/Cells4.cpp b/src/nupic/algorithms/Cells4.cpp index 2adc3b713a..a0dc8b2e1e 100644 --- a/src/nupic/algorithms/Cells4.cpp +++ b/src/nupic/algorithms/Cells4.cpp @@ -899,7 +899,7 @@ void Cells4::learnPhase2(bool readOnly) * Update the learning state. Called from compute() */ void Cells4::updateLearningState(const std::vector & activeColumns, - UInt* input) + Real* input) { // ========================================================================= // Copy over learning states to t-1 and reset state at t to 0 @@ -1230,7 +1230,7 @@ bool Cells4::inferPhase2() /** * Main compute routine, called for both learning and inference. */ -void Cells4::compute(UInt* input, UInt* output, bool doInference, bool doLearning) +void Cells4::compute(Real* input, Real* output, bool doInference, bool doLearning) { TIMER(computeTimer.start()); NTA_CHECK(doInference || doLearning); @@ -1436,7 +1436,7 @@ void Cells4::_updateAvgLearnedSeqLength(UInt prevSeqLength) /** * Go through the list of accumulated segment updates and process them. */ -void Cells4::processSegmentUpdates(UInt* input, const CState& predictedState) +void Cells4::processSegmentUpdates(Real* input, const CState& predictedState) { static std::vector delUpdates; delUpdates.clear(); // purge residual data diff --git a/src/nupic/algorithms/Cells4.hpp b/src/nupic/algorithms/Cells4.hpp index 2aef9d60fc..0b247ac2ea 100644 --- a/src/nupic/algorithms/Cells4.hpp +++ b/src/nupic/algorithms/Cells4.hpp @@ -356,7 +356,7 @@ namespace nupic { Real* _cellConfidenceCandidate; Real* _colConfidenceCandidate; - UInt* _tmpInputBuffer; + Real* _tmpInputBuffer; #if SOME_STATES_NOT_INDEXED CState _infActiveStateCandidate; CState _infPredictedStateCandidate; @@ -635,7 +635,7 @@ namespace nupic { * doInference: if true, inference output will be computed * doLearning: if true, learning will occur */ - void compute(UInt* input, UInt* output, bool doInference, bool doLearning); + void compute(Real* input, Real* output, bool doInference, bool doLearning); //----------------------------------------------------------------------- /** @@ -771,7 +771,7 @@ namespace nupic { * activeColumns: Indices of active columns */ void updateLearningState(const std::vector & activeColumns, - UInt* input); + Real* input); //----------------------------------------------------------------------- /** @@ -946,7 +946,7 @@ namespace nupic { * cell * */ - void processSegmentUpdates(UInt* input, const CState& predictedState); + void processSegmentUpdates(Real* input, const CState& predictedState); //---------------------------------------------------------------------- /** From 2ec73b8d39ad4a2a0bde55566001aa80469cba55 Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Mon, 2 Mar 2015 15:19:32 +0100 Subject: [PATCH 007/100] example TP.compute() call with Real[] --- src/examples/nupic/algorithms/HelloSP_TP.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/examples/nupic/algorithms/HelloSP_TP.cpp b/src/examples/nupic/algorithms/HelloSP_TP.cpp index 3bdd32a038..f269f4f1bb 100644 --- a/src/examples/nupic/algorithms/HelloSP_TP.cpp +++ b/src/examples/nupic/algorithms/HelloSP_TP.cpp @@ -68,8 +68,14 @@ const int DIM_INPUT = 10000; cout << "SP=" << outSP << endl; fill(outTP.begin(), outTP.end(), 0); -//! tp.compute(&input[0], &outTP[0], true, true); - cout << "TP=" << outTP << endl; + Real rIn[DIM]; + Real rOut[DIM]; + for (int i=0; i< DIM; i++) { + rIn[i] = (Real)(outSP[i]); + } + + tp.compute(rIn, rOut, true, true); + cout << "TP=" << rOut << endl; return 0; } From 50ce2fa1f95c923d7e22287c5f4e54d9537ba01b Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Mon, 2 Mar 2015 16:12:46 +0100 Subject: [PATCH 008/100] simplify --- src/examples/nupic/algorithms/HelloSP_TP.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/examples/nupic/algorithms/HelloSP_TP.cpp b/src/examples/nupic/algorithms/HelloSP_TP.cpp index f269f4f1bb..d57564226f 100644 --- a/src/examples/nupic/algorithms/HelloSP_TP.cpp +++ b/src/examples/nupic/algorithms/HelloSP_TP.cpp @@ -68,11 +68,19 @@ const int DIM_INPUT = 10000; cout << "SP=" << outSP << endl; fill(outTP.begin(), outTP.end(), 0); - Real rIn[DIM]; - Real rOut[DIM]; + Real rIn[DIM] = {}; + Real rOut[DIM] = {}; + //memset(rIn, 0, DIM * 4); + //memset(rOut, 0, DIM * 4); + + cout << "TP:" << endl; + for (int i=0; i< DIM; i++) { rIn[i] = (Real)(outSP[i]); + cout << rIn[i]; + cout << rOut[i]; } + cout << "OK" << endl; tp.compute(rIn, rOut, true, true); cout << "TP=" << rOut << endl; From 77ad64cd5fed99ec144f9892318c40513dbe1242 Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Mon, 2 Mar 2015 18:47:02 +0100 Subject: [PATCH 009/100] fix SP with params --- src/nupic/algorithms/SpatialPooler.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/nupic/algorithms/SpatialPooler.cpp b/src/nupic/algorithms/SpatialPooler.cpp index 20dd6106ce..3fc61e52e4 100644 --- a/src/nupic/algorithms/SpatialPooler.cpp +++ b/src/nupic/algorithms/SpatialPooler.cpp @@ -137,8 +137,7 @@ SpatialPooler::SpatialPooler(vector inputDimensions, UInt spVerbosity, bool wrapAround) { - SpatialPooler sp; - sp.initialize(inputDimensions, + initialize( inputDimensions, columnDimensions, potentialRadius, potentialPct, From 6922421d86b4eef2edfa6bc7c29d0e43c454c7d9 Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Mon, 2 Mar 2015 18:48:30 +0100 Subject: [PATCH 010/100] fixed SP in example --- src/examples/nupic/algorithms/HelloSP_TP.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/examples/nupic/algorithms/HelloSP_TP.cpp b/src/examples/nupic/algorithms/HelloSP_TP.cpp index d57564226f..59e9b265ae 100644 --- a/src/examples/nupic/algorithms/HelloSP_TP.cpp +++ b/src/examples/nupic/algorithms/HelloSP_TP.cpp @@ -58,8 +58,7 @@ const int DIM_INPUT = 10000; // cout << "input=" << input << endl; - SpatialPooler sp; //! (inputDim, colDim); - sp.initialize(inputDim, colDim); //! fix to use constructor above + SpatialPooler sp(inputDim, colDim); Cells4 tp(DIM); //run From 0bea36f1af11dc3eab0e36e486175a9cee8934b7 Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Tue, 3 Mar 2015 00:31:21 +0100 Subject: [PATCH 011/100] update --- src/examples/nupic/algorithms/HelloSP_TP.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/examples/nupic/algorithms/HelloSP_TP.cpp b/src/examples/nupic/algorithms/HelloSP_TP.cpp index 59e9b265ae..7184177242 100644 --- a/src/examples/nupic/algorithms/HelloSP_TP.cpp +++ b/src/examples/nupic/algorithms/HelloSP_TP.cpp @@ -59,7 +59,8 @@ const int DIM_INPUT = 10000; // cout << "input=" << input << endl; SpatialPooler sp(inputDim, colDim); - Cells4 tp(DIM); + Cells4 tp; + tp.initialize(DIM); //run fill(outSP.begin(), outSP.end(), 0); @@ -69,8 +70,6 @@ const int DIM_INPUT = 10000; fill(outTP.begin(), outTP.end(), 0); Real rIn[DIM] = {}; Real rOut[DIM] = {}; - //memset(rIn, 0, DIM * 4); - //memset(rOut, 0, DIM * 4); cout << "TP:" << endl; From 9dede13b0293c8b8c8d292959b36959a8a10ac4b Mon Sep 17 00:00:00 2001 From: Richard Crowder Date: Tue, 3 Mar 2015 12:36:22 +0000 Subject: [PATCH 012/100] Adding links and copy for MSVC and CMake --- external/windows64/README.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/external/windows64/README.md b/external/windows64/README.md index 8277957be3..62a2a7496b 100644 --- a/external/windows64/README.md +++ b/external/windows64/README.md @@ -7,6 +7,11 @@ Two environment variables must be setup before building the core; - NUPIC_CORE_SOURCE points to the root of the core directories, and - NUPIC_CORE points to an installation directory. +The following applications are required to rebuilt the core and external libraries; + +- [Microsoft Visual Studio Ultimate 2015 Preview](http://www.visualstudio.com/en-us/downloads/visual-studio-2015-downloads-vs) ([installer webpage](http://go.microsoft.com/?linkid=9863611&clcid=0x409)) +- [CMake](http://www.cmake.org/) (version 3.1 onwards to get the Visual Studio 2015 generator). + The following table shows the CMake-GUI settings for the core library. Using these table settings the %NUPIC_CORE% directory could equal the CMAKE_INSTALL_PREFIX directory. | Name | Value | @@ -15,13 +20,13 @@ The following table shows the CMake-GUI settings for the core library. Using the | Binaries | %NUPIC_CORE_SOURCE%/build/scripts | | CMAKE_INSTALL_PREFIX | %NUPIC_CORE_SOURCE%/build/release | -Note: The %NUPIC_CORE_SOURCE%/.gitignore file has a rule that ignores any directory called build/ from Git. Making it a convienient place to store build dependencies. +Note: The %NUPIC_CORE_SOURCE%/.gitignore file has a rule that ignores any directory called build/ from Git. Making it a convenient place to store build dependencies. The %NUPIC_CORE_SOURCE%/build/scripts/nupic_core.sln solution (v140 platform toolset) has an ALL_BUILD project that can rebuild the x64 Release version of the core library and test programs. As well as running the cpp_region test and unit tests. > At the time of writing; Two of the 12 projects fail when building the solution via Visual Studio or msbuild. The tests_cpp_region and tests_unit Utility projects both fail. Even though full debugging of the contained test projects all pass. The %NUPIC_CORE_SOURCE%/appveyor.yml file outlines script to unwrap the solution into individual msbuild steps, and which test programs to execute. -The INSTALL project has to be built seperately. External libraries (x64 release) are stored in the Git repository, and packaged into the deployed version. When the ALL_BUILD project completes, a separate run of the INSTALL project copies the binarys, header, and library files into the %NUPIC_CORE% directory. +The INSTALL project has to be built separately. External libraries (x64 release) are stored in the Git repository, and packaged into the deployed version. When the ALL_BUILD project completes, a separate run of the INSTALL project copies the binaries, header, and library files into the %NUPIC_CORE% directory. The NuPIC core library file is split into two files; @@ -46,7 +51,7 @@ The following libraries are embedded into the %NUPIC_CORE%/lib/nupic_core librar | Yaml Cpp | **0.3.0** | yaml-cpp-0.3.0.tar.gz | https://code.google.com/p/yaml-cpp/ | | Z Lib | **1.2.8** | zlib-1.2.8.tar.gz | http://www.zlib.net/ | -Extract them all into %NUPIC_CORE_SOURCE%/build directory. You may need to un-nest some of the directories, e.g. apr-1.5.1/apr-1.5.1/... to apr-1.5.1/... APR expects ceratin directory names, rename the following directories; +Extract them all into %NUPIC_CORE_SOURCE%/build directory. You may need to un-nest some of the directories, e.g. apr-1.5.1/apr-1.5.1/... to apr-1.5.1/... APR expects certain directory names, rename the following directories; apr-1.5.1 to apr apr-iconv-1.2.1 to apr-iconv @@ -70,7 +75,7 @@ apr.dsw and aprutil.dsw workspace files can be imported into Visual Studio 2015. Download version **0.5.0** from https://capnproto.org/capnproto-c++-win32-0.5.0.zip -The three executables found in %NUPIC_CORE_SOURCE%\build\capnproto-tools-win32-0.5.0 should match the %NUPIC_CORE_SOURCE%\external\windows64\bin executables, and tie in with the external capnp and kj common include directories. +The three executable files found in %NUPIC_CORE_SOURCE%\build\capnproto-tools-win32-0.5.0 should match the corresponding %NUPIC_CORE_SOURCE%\external\windows64\bin executable files, and tie in with the external capnp and kj common include directories. Install instructions can be found at https://capnproto.org/install.html This is an example Visual Studio Command Prompt line to invoke cmake and generator a solution and project files for Cap'n Proto. @@ -86,7 +91,7 @@ A valid libyaml.sln solution file can be found in directory yaml-0.1.5\win32\vs2 ### Yaml-cpp -In CMake-GUI %NUPIC_CORE_SOURCE%/build/yaml-cpp/ can be used for Source and Build directoreis. Make sure that MSVC_SHARED_RT is **ticked**, and BUILD_SHARED_LIBS and MSVC_STHREADED_RT are both **not ticked**. When building the solution you may need to `#include ` in src\ostream_wrapper.cpp +In CMake-GUI %NUPIC_CORE_SOURCE%/build/yaml-cpp/ can be used for Source and Build directories. Make sure that MSVC_SHARED_RT is **ticked**, and BUILD_SHARED_LIBS and MSVC_STHREADED_RT are both **not ticked**. When building the solution you may need to `#include ` in src\ostream_wrapper.cpp ### Z Lib From d2a0c7708c6c3941df541611d0e477ee4b360f1b Mon Sep 17 00:00:00 2001 From: Richard Crowder Date: Tue, 3 Mar 2015 16:07:48 +0000 Subject: [PATCH 013/100] Added gzip packaging for S3 upload --- appveyor.yml | 58 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 4fb626e404..148b7d1dfd 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,8 +5,6 @@ # version format version: 1.0.{build} -# TODO: Back to master before merge -# branches to build branches: # whitelist only: @@ -30,24 +28,16 @@ init: clone_folder: c:\projects\nupic-core environment: - matrix: -# - COMPILER_FAMILY: GNU -# DEPLOY_BUILD: 0 + # Must add either GCC or CLang here + # ie. COMPILER_FAMILY: GNU - COMPILER_FAMILY: MSVC DEPLOY_BUILD: 1 -install: - - mkdir C:\projects\nupic-core\build\ - - mkdir C:\projects\nupic-core\build\scripts - - mkdir C:\projects\nupic-core\build\release - - cd C:\projects\nupic-core\build\scripts - - ps: Start-FileDownload 'http://www.cmake.org/files/v3.1/cmake-3.1.0-win32-x86.zip' - - ps: Write-Host '7z x cmake-3.1.0-win32-x86.zip' - - ps: Start-Process -FilePath "7z" -ArgumentList "x -y cmake-3.1.0-win32-x86.zip" -Wait -Passthru - - set PATH="C:\projects\nupic-core\build\scripts\cmake-3.1.0-win32-x86\bin";%PATH% - - set PATH="C:\Program Files (x86)\MSBuild\14.0\Bin";%PATH% - - echo %PATH% +skip_commits: + # Add [av skip] to commit messages to skip AppVeyor building + # Add [ci skip] to skip Travis and AppVeyor building + message: /\[av skip\]/ #---------------------------------# # build configuration # @@ -63,6 +53,18 @@ assembly_info: configuration: Release +install: + - mkdir C:\projects\nupic-core\build\ + - mkdir C:\projects\nupic-core\build\release + - mkdir C:\projects\nupic-core\build\scripts + - cd C:\projects\nupic-core\build\scripts + - ps: Start-FileDownload 'http://www.cmake.org/files/v3.1/cmake-3.1.0-win32-x86.zip' + - ps: Write-Host '7z x cmake-3.1.0-win32-x86.zip' + - ps: Start-Process -FilePath "7z" -ArgumentList "x -y cmake-3.1.0-win32-x86.zip" -Wait -Passthru + - set PATH="C:\projects\nupic-core\build\scripts\cmake-3.1.0-win32-x86\bin";%PATH% + - set PATH="C:\Program Files (x86)\MSBuild\14.0\Bin";%PATH% + - echo %PATH% + before_build: - cd C:\projects\nupic-core\build\scripts - cmake C:\projects\nupic-core\src -G "Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX=..\Release -DLIB_STATIC_APR1_LOC=..\..\external\windows64\lib\apr-1.lib -DLIB_STATIC_APRUTIL1_LOC=..\..\external\windows64\lib\aprutil-1.lib -DLIB_STATIC_YAML_CPP_LOC=..\..\external\windows64\lib\yaml-cpp.lib -DLIB_STATIC_YAML_LOC=..\..\external\windows64\lib\yaml.lib -DLIB_STATIC_Z_LOC=..\..\external\windows64\lib\z.lib -DLIB_STATIC_CAPNP_LOC=..\..\external\windows64\lib\capnp.lib -DLIB_STATIC_KJ_LOC=..\..\external\windows64\lib\kj.lib @@ -78,17 +80,31 @@ build_script: - msbuild "C:\projects\nupic-core\build\scripts\Install.vcxproj" /p:Configuration=Release /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" after_build: + # Run the tests - cd C:\projects\nupic-core\build\release\bin - prototest 2>&1 - cpp_region_test 1 2>&1 - unit_tests --gtest_output=xml:${PROJECT_BUILD_ARTIFACTS_DIR}/unit_tests_report.xml 2>&1 - - ps: if($env:DEPLOY_BUILD -eq 1) { cd C:\projects\nupic-core\build\release\ } - - ps: if($env:DEPLOY_BUILD -eq 1) { copy C:\projects\nupic-core\Package.nuspec . } - - ps: if($env:DEPLOY_BUILD -eq 1) { nuget pack -version $env:APPVEYOR_BUILD_VERSION } - - ps: if($env:DEPLOY_BUILD -eq 1) { nuget push *.nupkg 30618afb-ecf6-4476-8e61-a5b823ad9892 } + + - cd C:\projects\nupic-core\build\release + - ps: >- + if($env:DEPLOY_BUILD -eq 1) { + copy C:\projects\nupic-core\Package.nuspec . + nuget pack -version $env:APPVEYOR_BUILD_VERSION + nuget push *.nupkg 30618afb-ecf6-4476-8e61-a5b823ad9892 + + Write-Host '7z a -ttar nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar .' + Start-Process -FilePath "7z" -ArgumentList "a -ttar nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar ." -Wait -Passthru + Write-Host '7z a -tgzip nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar' + Start-Process -FilePath "7z" -ArgumentList "a -tgzip nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar" -Wait -Passthru + } + + - cd C:\projects\nupic-core\build\release + - copy *.nupkg ${PROJECT_BUILD_ARTIFACTS_DIR} + - copy nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz ${PROJECT_BUILD_ARTIFACTS_DIR} artifacts: - - path: nupic-core\build\release + - path: build\artifacts test: off deploy: off From cbb63089fd0925e9341ceb77d3390e530154854d Mon Sep 17 00:00:00 2001 From: Richard Crowder Date: Tue, 3 Mar 2015 16:10:55 +0000 Subject: [PATCH 014/100] Make sure AppVeyor is aware of our feature branch --- appveyor.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/appveyor.yml b/appveyor.yml index 148b7d1dfd..4105b6b495 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -9,6 +9,7 @@ branches: # whitelist only: - master + - 311-appveyor-s3-support # blacklist except: From b370ef80b0d9c4d52d83ae8fe6327aec03389ee3 Mon Sep 17 00:00:00 2001 From: Richard Crowder Date: Tue, 3 Mar 2015 16:20:54 +0000 Subject: [PATCH 015/100] Kick appveyor --- appveyor.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 4105b6b495..168760fb44 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -8,7 +8,6 @@ version: 1.0.{build} branches: # whitelist only: - - master - 311-appveyor-s3-support # blacklist From 22a28b88132c2463444108b5c1a8249e963050d2 Mon Sep 17 00:00:00 2001 From: Richard Crowder Date: Tue, 3 Mar 2015 16:48:51 +0000 Subject: [PATCH 016/100] Revert "Kick appveyor" This reverts commit b370ef80b0d9c4d52d83ae8fe6327aec03389ee3. --- appveyor.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/appveyor.yml b/appveyor.yml index 168760fb44..4105b6b495 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -8,6 +8,7 @@ version: 1.0.{build} branches: # whitelist only: + - master - 311-appveyor-s3-support # blacklist From 73163da15e212f4fe50c87eb434a29b21337d32e Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Tue, 3 Mar 2015 21:46:02 +0100 Subject: [PATCH 017/100] better code thanks @rcrowder ! --- src/examples/nupic/algorithms/HelloSP_TP.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/examples/nupic/algorithms/HelloSP_TP.cpp b/src/examples/nupic/algorithms/HelloSP_TP.cpp index 7184177242..5eb247e66a 100644 --- a/src/examples/nupic/algorithms/HelloSP_TP.cpp +++ b/src/examples/nupic/algorithms/HelloSP_TP.cpp @@ -64,7 +64,7 @@ const int DIM_INPUT = 10000; //run fill(outSP.begin(), outSP.end(), 0); - sp.compute(&input[0], true, &outSP[0]); + sp.compute(input.data(), true, outSP.data()); cout << "SP=" << outSP << endl; fill(outTP.begin(), outTP.end(), 0); From 4deee7bba76d27ef7ce3e66fec757fcd45893819 Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Tue, 3 Mar 2015 22:35:19 +0100 Subject: [PATCH 018/100] Cells4: rename param doItAll to self-explanatory initFromCpp --- src/nupic/algorithms/Cells4.cpp | 8 ++++---- src/nupic/algorithms/Cells4.hpp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/nupic/algorithms/Cells4.cpp b/src/nupic/algorithms/Cells4.cpp index a0dc8b2e1e..ba36332960 100644 --- a/src/nupic/algorithms/Cells4.cpp +++ b/src/nupic/algorithms/Cells4.cpp @@ -79,7 +79,7 @@ Cells4::Cells4(UInt nColumns, UInt nCellsPerCol, Real globalDecay, bool doPooling, int seed, - bool doItAll, + bool initFromCpp, bool checkSynapseConsistency) : _rng(seed < 0 ? rand() : seed) { @@ -97,7 +97,7 @@ Cells4::Cells4(UInt nColumns, UInt nCellsPerCol, permInc, globalDecay, doPooling, - doItAll, + initFromCpp, checkSynapseConsistency); } @@ -2235,7 +2235,7 @@ Cells4::initialize(UInt nColumns, Real permInc, Real globalDecay, bool doPooling, - bool doItAll, + bool initFromCpp, bool checkSynapseConsistency) { _nColumns = nColumns; @@ -2282,7 +2282,7 @@ Cells4::initialize(UInt nColumns, // Python allocate numpy arrays and pass them to C++, or C++ // allocate memory here (then Python gets pointers via // getStatePointers). - if (doItAll) { + if (initFromCpp) { _ownsMemory = true; _infActiveStateT.initialize(_nCells); _infActiveStateT1.initialize(_nCells); diff --git a/src/nupic/algorithms/Cells4.hpp b/src/nupic/algorithms/Cells4.hpp index 0b247ac2ea..c41b8165f7 100644 --- a/src/nupic/algorithms/Cells4.hpp +++ b/src/nupic/algorithms/Cells4.hpp @@ -408,7 +408,7 @@ namespace nupic { Real globalDecay =0, bool doPooling =false, int seed =42, - bool doItAll =false, + bool initFromCpp =false, bool checkSynapseConsistency =false); @@ -430,7 +430,7 @@ namespace nupic { Real permInc =.1, Real globalDecay =.1, bool doPooling =false, - bool doItAll =false, + bool initFromCpp =false, bool checkSynapseConsistency =false); //---------------------------------------------------------------------- From 16bddffd1a63a2de2bd420d48f6a3457c0652ba6 Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Tue, 3 Mar 2015 22:38:29 +0100 Subject: [PATCH 019/100] Cells4: working default c++ constructor by enabling initFromCpp=true which setups needed structures in C++. If needed, initFromCpp can be false and use structures passed from numpy - this is used in python bindings. Thanks @rcrowder for this!! --- src/nupic/algorithms/Cells4.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nupic/algorithms/Cells4.hpp b/src/nupic/algorithms/Cells4.hpp index c41b8165f7..6b8a60db66 100644 --- a/src/nupic/algorithms/Cells4.hpp +++ b/src/nupic/algorithms/Cells4.hpp @@ -408,7 +408,7 @@ namespace nupic { Real globalDecay =0, bool doPooling =false, int seed =42, - bool initFromCpp =false, + bool initFromCpp =true, bool checkSynapseConsistency =false); From 2f702d9d75969a5bdc8a04e2efe1c41709929a41 Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Wed, 4 Mar 2015 00:01:09 +0100 Subject: [PATCH 020/100] fix size for rOut --- src/examples/nupic/algorithms/HelloSP_TP.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/examples/nupic/algorithms/HelloSP_TP.cpp b/src/examples/nupic/algorithms/HelloSP_TP.cpp index 5eb247e66a..00680b0b67 100644 --- a/src/examples/nupic/algorithms/HelloSP_TP.cpp +++ b/src/examples/nupic/algorithms/HelloSP_TP.cpp @@ -68,8 +68,9 @@ const int DIM_INPUT = 10000; cout << "SP=" << outSP << endl; fill(outTP.begin(), outTP.end(), 0); - Real rIn[DIM] = {}; - Real rOut[DIM] = {}; + Real rIn[DIM] = {}; // default size from constructor + const UInt CELLS = DIM*10; + Real rOut[CELLS] = {}; cout << "TP:" << endl; From 9571d3934f2f113bb4bf71f516b7b2e0f76a328c Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Wed, 4 Mar 2015 00:24:14 +0100 Subject: [PATCH 021/100] enable debug mode at compile time when cmake -DCMAKE_BUILD_TYPE=Debug --- src/CMakeLists.txt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index aa02219279..6e23affb4d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -188,9 +188,13 @@ else() set(COMMON_LINK_FLAGS "${COMMON_LINK_FLAGS} -static-libstdc++") endif() endif() -set(COMMON_COMPILE_FLAGS "${COMMON_COMPILE_FLAGS} ${OPTIMIZATION_FLAGS_CC}") -set(COMMON_LINK_FLAGS "${COMMON_LINK_FLAGS} ${OPTIMIZATION_FLAGS_LT}") - +if(${CMAKE_BUILD_TYPE} STREQUAL "Debug") + set(COMMON_COMPILE_FLAGS "${COMMON_COMPILE_FLAGS} -Og -g") + set(COMMON_LINK_FLAGS "${COMMON_LINK_FLAGS} -O0") +else() + set(COMMON_COMPILE_FLAGS "${COMMON_COMPILE_FLAGS} ${OPTIMIZATION_FLAGS_CC}") + set(COMMON_LINK_FLAGS "${COMMON_LINK_FLAGS} ${OPTIMIZATION_FLAGS_LT}") +endif() # # Let CMake know where all of the external files are. From 7639389777f3f7037076bc2230c530c8caa6caa2 Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Wed, 4 Mar 2015 01:47:18 +0100 Subject: [PATCH 022/100] tiny fix --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6e23affb4d..c8ad9edc5f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -188,7 +188,7 @@ else() set(COMMON_LINK_FLAGS "${COMMON_LINK_FLAGS} -static-libstdc++") endif() endif() -if(${CMAKE_BUILD_TYPE} STREQUAL "Debug") +if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") set(COMMON_COMPILE_FLAGS "${COMMON_COMPILE_FLAGS} -Og -g") set(COMMON_LINK_FLAGS "${COMMON_LINK_FLAGS} -O0") else() From 88a02a9730eca16d51c8107acee0dea8c09adbee Mon Sep 17 00:00:00 2001 From: David Ragazzi Date: Thu, 5 Mar 2015 13:40:02 -0300 Subject: [PATCH 023/100] Revert "Remove obsolete implementations of SP" --- src/nupic/algorithms/FDRCSpatial.hpp | 1796 ++++++++++++++++++++++++++ src/nupic/algorithms/FDRSpatial.hpp | 1000 ++++++++++++++ 2 files changed, 2796 insertions(+) create mode 100644 src/nupic/algorithms/FDRCSpatial.hpp create mode 100644 src/nupic/algorithms/FDRSpatial.hpp diff --git a/src/nupic/algorithms/FDRCSpatial.hpp b/src/nupic/algorithms/FDRCSpatial.hpp new file mode 100644 index 0000000000..0886860962 --- /dev/null +++ b/src/nupic/algorithms/FDRCSpatial.hpp @@ -0,0 +1,1796 @@ +/* --------------------------------------------------------------------- + * Numenta Platform for Intelligent Computing (NuPIC) + * Copyright (C) 2013, Numenta, Inc. Unless you have an agreement + * with Numenta, Inc., for a separate license for this software code, the + * following terms and conditions apply: + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses. + * + * http://numenta.org/licenses/ + * --------------------------------------------------------------------- + */ + +#ifndef NTA_FDR_C_SPATIAL_HPP +#define NTA_FDR_C_SPATIAL_HPP + +#include + +#if defined(NTA_ARCH_64) && defined(NTA_OS_LINUX) +#define P_INC 4 // TODO: set for other 64bits too? Or set to sizeof(int*) instead? +#else +#define P_INC 2 +#endif + +namespace nupic { + namespace algorithms { + + //-------------------------------------------------------------------------------- + /** + * The FDRSpatial class stores binary 0/1 coincidences and computes the degree + * of match between an input vector (binary 0/1) and each coincidence, to output + * a sparse (binary 0/1) "representation" of the input vector in terms of the + * coincidences. The degree of match is simply the number of bits that overlap + * between each coincidence and the input vector. Only the top-N best matches are + * turned on in the output, and the outputs always have the same, fixed number + * of bits turned on (N), according to FDR principles. + * + * The coincidences can be learnt, in which case the non-zeros of the coincidences + * that match the inputs best are reinforced while others are gradually forgotten. + * Learning is online and the coincidences can adapt to the changing statistics + * of the inputs. + * + * NOTE: + * there are two thresholds used in this class: + * - stimulus_threshold is used to decide whether a coincidence matches the + * input vector well enough or not. It is a hurdle that the coincidence has + * to pass in order to participate in the representation of the input, removing + * coincidences that would have only an insignificant number of bits matching + * the input. + * - histogram_threshold is used, with learning only, to decide which bits from + * the coincidences are more important and can participate in matching the + * input. Bits with a count lower than histogram_threshold are kept in the + * coincidence, but they do not participate to match the input. + * + * IMPLEMENTATION NOTE: + * Each row (coincidence) has exactly nnzpr non-zeros. + * The non-zeros are represented by pairs (index,count) of type (uint,float), + * and we call that type 'IndNZ'. Since all the rows have the same number of + * non-zeros, we use a compact storage where all the non-zeros are stored in + * a vector (of immutable size = nrows * nnzpr), and this vector is called + * 'ind_nz'. The k-th non-zero of row i is at position: ind_nz[i*nnzpr+k]. + * + * IMPLEMENTATION NOTE: + * In order to optimize speed, the non-zeros of each coincidence are stored in + * such a way that the non-zeros which have a count > histogram_threshold appear + * first, and the others after. The boundary between those two sets is maintained + * in ub[i] for each row i. These two sets are updated in update(). In infer(), + * only the non-zeros up to ub[i] are used to compute the match of coincidence i + * and the input vector. + */ + + //-------------------------------------------------------------------------------- + /* + struct Timer + { + struct timeval t0, t1; + + inline Timer() { gettimeofday(&t0, NULL); } + inline void start() { gettimeofday(&t0, NULL); } + inline void restart() { gettimeofday(&t0, NULL); } + inline double elapsed() + { + gettimeofday(&t1, NULL); + return t1.tv_sec+1e-6*t1.tv_usec - (t0.tv_sec+1e-6*t0.tv_usec); + } + }; + */ + + //-------------------------------------------------------------------------------- + class Inhibition + { + public: + typedef nupic::UInt32 size_type; + typedef nupic::Real32 value_type; + + private: + size_type small; + size_type c_height, c_width, c_field_size; + size_type inhibition_radius; + std::vector > inhibition_area; + + public: + //-------------------------------------------------------------------------------- + inline Inhibition(size_type _c_height =0, size_type _c_width =0, + value_type _desired_density =1.0f, + size_type _small =0) + { + initialize(_c_height, _c_width, _desired_density, _small); + } + + //-------------------------------------------------------------------------------- + inline void initialize(size_type _c_height =0, size_type _c_width =0, + value_type _desired_density =1.0f, + size_type _small =0) + { + small = _small; + c_height = _c_height; + c_width = _c_width; + c_field_size = c_height * c_width; + inhibition_radius = size_type(sqrt(1.0f/_desired_density) - 1.0f); + + if (estimate_max_size_bytes() > 600*1024*1024) + small = 1; + + if (small == 1) { + inhibition_area.resize(0); + return; + } + + inhibition_area.resize(c_field_size); + + for (size_type c = 0; c != c_field_size; ++c) { + + // so that we can reinitialize, for example when + // we change the desired density + inhibition_area[c].resize(0); + + int ch = c / c_width; + int cw = c % c_width; + int lb_height = std::max((int) 0, ch - (int) inhibition_radius); + int ub_height = std::min(ch + inhibition_radius + 1, c_height); + int lb_width = std::max((int) 0, cw - (int) inhibition_radius); + int ub_width = std::min(cw + inhibition_radius + 1, c_width); + + for (int py = lb_height; py != ub_height; ++py) { + for (int px = lb_width; px != ub_width; ++px) { + int w = px + c_width * py; + if (w != (int) c) + inhibition_area[c].push_back(w); + } + } + } + } + + //-------------------------------------------------------------------------------- + inline int getSmall() const { return small; } + inline size_type getInhibitionRadius() const { return inhibition_radius; } + inline size_type getHeight() const { return c_height; } + inline size_type getWidth() const { return c_width; } + inline size_type n_bytes() const { return nupic::n_bytes(inhibition_area); } + + //-------------------------------------------------------------------------------- + inline size_type estimate_max_size_bytes() const + { + size_type a = 0; + + for (size_type c = 0; c != c_field_size; ++c) { + + int ch = c / c_width; + int cw = c % c_width; + int lb_height = std::max((int) 0, ch - (int) inhibition_radius); + int ub_height = std::min(ch + inhibition_radius + 1, c_height); + int lb_width = std::max((int) 0, cw - (int) inhibition_radius); + int ub_width = std::min(cw + inhibition_radius + 1, c_width); + + a += (ub_height - lb_height) * (ub_width - lb_width); + } + + return a * sizeof(int); + } + + //-------------------------------------------------------------------------------- + inline void setDesiredOutputDensity(value_type v) + { + initialize(c_height, c_width, v, small); + } + + //-------------------------------------------------------------------------------- + /* + * TODO: precompute deltas on which to compute the max, or + * sometimes compute on a whole square if max was in the delta + * removed. This retests the same pixels over and over again. + * Don't forget that there are deltas added and deltas removed. + * Maybe store the indices of the columns in inhibition radius + * as well as the deltas. + * TODO: as soon as greater value than y[c] / .95 found in the new + * delta, cell is inhibited + */ + template + inline size_type compute(It1 x, It2 y, size_type stimulus_threshold =0, + value_type k =.95f) + { + size_type n_active = 0; + + if (small == 0) { + + for (size_type c = 0; c != c_field_size; ++c) { + + if (x[c] <= stimulus_threshold) + continue; + + value_type val_c = x[c] / k; + size_type* w = &inhibition_area[c][0]; + size_type* w_end = w + inhibition_area[c].size(); + + while (w != w_end && val_c > x[*w]) + ++w; + + if (w == w_end) + y[n_active++] = c; + } + + } else if (small == 1) { + + for (size_type c = 0; c != c_field_size; ++c) { + + if (x[c] <= stimulus_threshold) + continue; + + value_type val_c = x[c] / k; + + int ch = c / c_width; + int cw = c % c_width; + int lb_height = std::max((int) 0, ch - (int) inhibition_radius); + int ub_height = std::min(ch + inhibition_radius + 1, c_height); + int lb_width = std::max((int) 0, cw - (int) inhibition_radius); + int ub_width = std::min(cw + inhibition_radius + 1, c_width); + + bool stop = false; + + for (int px = lb_width; px != ub_width && !stop; ++px) { + for (int py = lb_height; py != ub_height && !stop; ++py) { + size_type w = (size_type) px + c_width * (size_type) py; + if (w == c) + continue; + stop = val_c <= x[w]; + } + } + + if (!stop) + y[n_active++] = c; + } + } + + return n_active; + } + }; + + //-------------------------------------------------------------------------------- + // used for the old-fashioned sort in Inhibition2::compute() + // + // We would put this inside the function, but gcc 4.5 busts us. + // A language lawyer explains that C++98/03 (the current one) does + // not allow instantiation of a template with a local type. + template + struct CMySort + { + typedef nupic::UInt32 size_type; + It _x; + CMySort(It& x) : _x(x) {} + bool operator()(size_type A, size_type B) const { + return _x[A] > _x[B]; + } + }; + + //-------------------------------------------------------------------------------- + //-------------------------------------------------------------------------------- + /* + * This class implements cell inhibition. Given a region of cells and their + * firing strengths, it returns the list of indices of the cells that are + * firing after inhibition. + * + * Inhibition is computed per "inhibition area" within the layer. The + * size of the inhibition area is controlled by the '_inhibition_radius' + * construction parameter. An inhibition area is a square section of cells + * with a width and height of (_inhibition_radius * 2 + 1). + * + * A cell is only allowed to fire if it is among the top N% strongest cells + * within the inhibition area centered around itself, where N is given by the + * construction parameter '_local_area_density'. + * + */ + class Inhibition2 + { + public: + typedef nupic::UInt32 size_type; + typedef nupic::Real32 value_type; + + private: + size_type c_height, c_width, c_field_size; + size_type inhibition_radius; + value_type local_area_density; + + public: + //-------------------------------------------------------------------------------- + // Parameters: + // _c_height: height of the region, in cells + // _c_width: width of the region, in cells + // _inhibition_radius: inhibition radius, in cells + // _local_area_density: desired local area density within each + // inhibition area. + // + inline Inhibition2(size_type _c_height =0, size_type _c_width =0, + size_type _inhibition_radius =10, + value_type _local_area_density =0.02f) + { + initialize(_c_height, _c_width, _inhibition_radius, _local_area_density); + } + + //-------------------------------------------------------------------------------- + // Parameters: + // _c_height: height of the region, in cells + // _c_width: width of the region, in cells + // _inhibition_radius: inhibition radius, in cells + // _local_area_density: desired local area density within each + // inhibition area. + // + inline void initialize(size_type _c_height =0, size_type _c_width =0, + size_type _inhibition_radius =10, + value_type _local_area_density =0.02f) + { + NTA_ASSERT(0 < _local_area_density && _local_area_density <= 1); + + c_height = _c_height; + c_width = _c_width; + c_field_size = c_height * c_width; + inhibition_radius = _inhibition_radius; + local_area_density = _local_area_density; + } + + //-------------------------------------------------------------------------------- + // Various getter methods + inline size_type getInhibitionRadius() const { return inhibition_radius; } + inline value_type getLocalAreaDensity() const { return local_area_density; } + inline size_type getHeight() const { return c_height; } + inline size_type getWidth() const { return c_width; } + + //-------------------------------------------------------------------------------- + // Modify the desired local area density. + inline void setDesiredOutputDensity(value_type v) + { + initialize(c_height, c_width, inhibition_radius, v); + } + + //-------------------------------------------------------------------------------- + // Compute which cells are firing after inhibition. On return, + // the y array will be filled in with the cell indices of the cells that are + // firing after inhibition. The number of firing cells placed into the + // y array is given by the return value. + // + // Parameters: + // x: array of cell firing strengths + // y: space to hold output cell indices + // stimulus_threshold: Any cell with an overlap of less than + // stimulusThreshold is not allowed to win + // add_to_winners: Typically a very small number (like .00001) + // that gets added to the firing strength + // of each cell that wins as we go along. This + // prevents us from returning more than the + // desired density of cells when many cells + // are firing with the exact same strength. + template + inline size_type compute(It1 x, It2 y, value_type stimulus_threshold =0, + value_type add_to_winners =0) + { + // This holds the total number of active cells firing after inhibition + size_type n_active = 0; + + if (inhibition_radius >= c_field_size - 1) { // optimized special case + static std::vector vectIndices; + vectIndices.clear(); // purge residual data + + // get the columns with non-trivial values + for (size_type c = 0; c != c_field_size; ++c) { + if (x[c] >= stimulus_threshold) + vectIndices.push_back(c); + } + + // sort the qualified columns in descending value order +#if 0 + // the lambda sort function requires -std=c++0x or -std=gnu++0x, + // first supported in gnu 4.5, but our usage here busts in 4.5.2 + // and may first work in 4.6, not yet available pre-packaged for + // Ubuntu 11.04. + std::sort(vectIndices.begin(), vectIndices.end(), []( size_type a, size_type b) { return x[a] > x[b] ; }) ; +#else + // sort the old-fashioned way + CMySort s(x); + std::sort(vectIndices.begin(), vectIndices.end(), s); +#endif + + // compute how many columns we want + size_type top_n = size_type(0.5 + local_area_density * c_field_size); + if (top_n == 0) + top_n = 1; + + // select the top_n biggest values, less if there aren't enough + if (vectIndices.size() > top_n) + vectIndices.resize(top_n); + std::sort(vectIndices.begin(), vectIndices.end()); // must the returned indices be sorted? + while (n_active < vectIndices.size()) { + y[n_active] = vectIndices[n_active]; + n_active++; + } + + } // optimized special case + else { + + // ------------------------------------------------------------------ + // For every cell in this region.... + for (size_type c = 0; c != c_field_size; ++c) { + + // If the firing strength of this cell is below stimulus threshold, + // it's not allowed to fire + if (x[c] < stimulus_threshold) + continue; + + + // ------------------------------------------------------------------ + // Get the bounds of the inhibition area around this cell + int ch = c / c_width; // The column index of this cell + int cw = c % c_width; // The row index of this cell + + // the index of top of the inhibition area + int lb_height = std::max((int) 0, ch - (int) inhibition_radius); + + // the index of bottom of the inhibition area + int ub_height = std::min(ch + inhibition_radius + 1, c_height); + + // the index of left side of the inhibition area + int lb_width = std::max((int) 0, cw - (int) inhibition_radius); + + // the index of right side of the inhibition area + int ub_width = std::min(cw + inhibition_radius + 1, c_width); + + + // ---------------------------------------------------------------- + // How many cells are allowed to be on within this inhibition area? + // Put that into top_n + size_type top_n = + (size_type) (0.5 + local_area_density + * (ub_height - lb_height) * (ub_width - lb_width)); + if (top_n == 0) + top_n = 1; + + + // ---------------------------------------------------------------- + // Iterate over all other cells within this inhibition area. Keep a count + // of how many are firing STRONGER than this cell. This count goes + // into k. + int k = 0; + for (int px = lb_width; px != ub_width && k < (int) top_n; ++px) + for (int py = lb_height; py != ub_height && k < (int) top_n; ++py) + if (x[(size_type)px + c_width * (size_type)py] > x[c]) + ++k; + + + // ---------------------------------------------------------------- + // If this cell is within the top_n strongest cells, then it is allowed + // to fire. + // + // Take a note of the following example scenario to explain why we need + // add_to_winners: + // 1.) top_n is 10 + // 2.) there are 20 cells in the inhibition area all firing with + // strength 0.8, all other cells are firing less than 0.8 + // 3.) the current cell is firing with strength 0.8. + // + // In this scenario, k will be 0 because no other cells are firing + // stronger than the current cell and we will decide to fire this + // cell. Likewise, for each of the other 20 cells, they will also + // calculate a k of 0 and will also decide to fire. In the end, we + // will end up with 20 firing cells, when the user wanted only 10. + // + // To address this, we add a small factor to each cell's firing strength + // when we decide to fire it. In this way, the first 10 cells that + // we scan with strength 0.8 will get boosted to strength + // 0.8+add_to_winners, and the next 10 will NOT fire because their + // k will be > 10. + // + if (k < (int) top_n) { + y[n_active++] = c; + // add_to_winners prevents us from choosing more than top_n winners + // per inhibition region when more than top_n all have the same + // highest score. + x[c] += add_to_winners; + } + } // for every cell in this region + } // if not the optimized special case + return n_active; + } + }; + + //-------------------------------------------------------------------------------- + //-------------------------------------------------------------------------------- + class FDRCSpatial + { + public: + typedef nupic::UInt32 size_type; + typedef nupic::Real32 value_type; + typedef std::pair IndNZ; + + public: + //-------------------------------------------------------------------------------- + /** + * Constructor for SP. + * + * Creates a random sparse matrix with uniformly distributed non-zeros, all the + * non-zeros having value 1, unless _clone is true, in which case the coincidence + * matrix is not set here, but can be set later from a SM with set_cm. + * The coincidences are sparse 0/1 vectors (vertices of the unit hypercube of + * dimension input_width). + * + * Parameters: + * ========== + * - nbabies: the number of babies in this FDR SP + * _ c_height, c_width: the shape of the coincidence array + * - nrows: the number of coincidence vectors + * - input_width: the size of each coincidence vector (number of elements) + * - nnzpr: number of non-zeros per row, i.e. number of non-zeros in each + * binary coincidence + * - density: number of non-zeros in result vector for infer() ( <= nrows) + * - stimulus_threshold: minimum number of bits in the input that need to + * match with one coincidence for the input vector. If that threshold + * is not met by a pair (coincidence,input), the output for that + * coincidence is zero + * - sparsity_algo: which sparsity enforcing algo to use: globalMax or cellSweeper + * - desired_density: how many non-zeros should each output contain + * - clone: whether to clone this spatial pooler or not. Two or more spatial + * poolers that are cloned share the same coincidences. + * - coincidence_type: the type of coincidence to use. The type determines + * the distribution of the non-zeros inside the coincidence. + * Available types: uniform, gaussian. If gaussian, specify rf_x + * and sigma. + * - rf_x: length of the receptive field in each coincidence in gaussian + * mode: > 0, input_width % rf_x == 0. + * - sigma: sigma for the gaussian distribution when using gaussian + * coincidences, > 0. + * - seed: random seed, that can be set to make runs repeatable. This seed + * influences only the initial random coincidence matrix. There is + * no randomness in the rest of the algorithm. + * - init_nz_val: initial value of the counts for each bit of each coincidence + * (used in learning) + * - threshold_cte: determines histogram threshold, that is, bit count that + * that needs to be exceeded for coincidence bit to participate + * in matching (see learning) + * - normalization_sum: value to which the sum of the bit counts for each + * coincidence is normalized to (reduces the likelihood of a + * coincidence bit to participate in further matching, see learning) + * - normalization_freq: how often normalization is performed + * - hysteresis: Must be >= 1.0. == 1.0 by default. If > 1.0, then outputs that + * were present in the sparse output of the previous time step will + * have their values multiplied by hysteresis before choosing the + * winners in the current time step. + * + * NOTE: + * FDRSpatial starts with learning off. + * + * IMPLEMENTATION NOTE: + * Don't forget to initialize ub to nnzpr for each row, so that we multiply + * correctly in infer when not using learning. + */ + FDRCSpatial(size_type _input_height, size_type _input_width, + size_type _c_height, size_type _c_width, + size_type _c_rf_radius, size_type _c_pool_size, size_type _c_nnz, + value_type _desired_density_learning =.1f, + value_type _desired_density_inference =.1f, + size_type _stimulus_threshold_learning =0, + size_type _stimulus_threshold_inference =1, + value_type _convolution_k_learning =.95f, + value_type _convolution_k_inference =.95f, + int _seed =-1, + value_type _threshold_cte =800.0f, + value_type _normalization_sum =1000.0f, + size_type _clone_height =0, size_type _clone_width =0, + size_type small_threshold_bytes =600*1024*1024) // MB + : rng(_seed == -1 ? rand() : _seed), + input_size(_input_height * _input_width), + input_height(_input_height), input_width(_input_width), + c_height(_c_height), c_width(_c_width), + c_field_size(_c_height * _c_width), + c_rf_radius(_c_rf_radius), + c_pool_size(_c_pool_size), + c_nnz(_c_nnz), + c_rf_side(2*c_rf_radius+1), + c_rf_size(c_rf_side * c_rf_side), + n_masters(_clone_height > 0 ? _clone_height * _clone_width : c_field_size), + clone_height(_clone_height), clone_width(_clone_width), + desired_density_learning(_desired_density_learning), + desired_density_inference(_desired_density_inference), + stimulus_threshold_learning(_stimulus_threshold_learning), + stimulus_threshold_inference(_stimulus_threshold_inference), + convolution_k_learning(_convolution_k_learning), + convolution_k_inference(_convolution_k_inference), + histogram_threshold((value_type) _threshold_cte / (value_type) _c_nnz), + normalization_sum(_normalization_sum), + n_active(0), + small(isCloned() && estimate_max_size_bytes() > small_threshold_bytes), + ind_nz(0), + hists(n_masters * c_pool_size), + cl_map(0), + inv_cl_map(0), + int_buffer(std::max(c_rf_size, c_field_size), 0), + d_output(0), + inhibition(c_height, c_width, desired_density_learning), + yy(getNColumns(), 0), + t_ind() + { + { // Pre-conditions + NTA_ASSERT(!(isCloned() == false && small == true)); + NTA_ASSERT((clone_height == 0 && clone_width == 0) + || clone_height * clone_width != 0); + NTA_ASSERT(c_nnz <= c_pool_size); + NTA_ASSERT(c_pool_size <= (2 * c_rf_radius + 1) * (2 * c_rf_radius + 1)); + NTA_ASSERT(0 < histogram_threshold); + NTA_ASSERT(0 < normalization_sum); + } // End pre-conditions + + initialize_cl_maps(); + initialize_rfs(); + initialize_ind_nz(); // needs rfs and cl_maps + add_val(hists.begin(), hists.end(), 100); + normalize(); + + greater_2nd_p order; + + for (size_type i = 0; i != indNZNRows(); ++i) { + IndNZ *beg = row_begin(i), *end = beg + c_pool_size; + std::partial_sort(beg, beg + c_nnz, end, order); + } + + { // Post-conditions + NTA_ASSERT((small && ind_nz.size() == n_masters * c_pool_size) + || (!small && ind_nz.size() == c_field_size * c_pool_size)); + } // End post-conditions + } + + private: + //-------------------------------------------------------------------------------- + inline void initialize_cl_maps() + { + if (!isCloned()) + return; + + cl_map.resize(c_field_size); + inv_cl_map.resize(getNMasters()); + + for (size_type i = 0; i != getNMasters(); ++i) + inv_cl_map[i].clear(); + + for (size_type i = 0; i != c_field_size; ++i) { + cl_map[i] = clone_width * ((i / c_width) % clone_height) + + (i % c_width) % clone_width; + inv_cl_map[cl_map[i]].push_back(i); + } + + { // Post-conditions + for (size_type i = 0; i != inv_cl_map.size(); ++i) { + NTA_ASSERT(inv_cl_map[i].size() < c_field_size); + for (size_type j = 0; j != inv_cl_map[i].size(); ++j) + NTA_ASSERT(inv_cl_map[i][j] < c_field_size); + } + } + } + + //-------------------------------------------------------------------------------- + inline void initialize_rfs() + { + // compute all receptive fields and store their boundaries + // step is in float, but the rest in double to emulate what numpy + // is doing and get an exact match with Python in unit tests. + double start_height = c_rf_radius; + double stop_height = (input_height - 1) - c_rf_radius + 1; + float step_height = (stop_height - start_height) / double(c_height); + double start_width = c_rf_radius; + double stop_width = (input_width - 1) - c_rf_radius + 1; + float step_width = (stop_width - start_width) / double(c_width); + double fch = start_height; + double fcw = start_width; + + // Could avoid storing this one, except for getMasterLearnedCoincidence, + // used by the inspectors + rfs.resize(4 * c_field_size); + size_type* rfs_p = & rfs[0]; + size_type c_idx = 0; + + for (int i = 0; i != (int) c_height; ++i, fch += step_height) { + fcw = start_width; + for (int j = 0; j != (int) c_width; ++j, fcw += step_width, ++c_idx) { + + NTA_ASSERT(c_idx < c_field_size); + + int ch = (int) fch, cw = (int) fcw; + *rfs_p++ = ch - c_rf_radius; + *rfs_p++ = ch + c_rf_radius + 1; + *rfs_p++ = cw - c_rf_radius; + *rfs_p++ = cw + c_rf_radius + 1; + } + } + } + + //-------------------------------------------------------------------------------- + inline void initialize_ind_nz(size_type* indnz =NULL) + { + ind_nz.resize((small ? n_masters : c_field_size) * c_pool_size); + + std::vector m_ind, perm(c_rf_size); + for (size_type ii = 0; ii != c_rf_size; ++ii) + perm[ii] = ii; + + if (!indnz) { // initialization in constructor + + if (isCloned()) { // cloned initialization, in constructor + + // TODO: get rid of int_buffer? + for (size_type i = 0; i != c_rf_size; ++i) + int_buffer[i] = i; + + m_ind.resize(n_masters * c_pool_size); + + for (size_type i = 0; i != n_masters; ++i) { + std::random_shuffle(perm.begin(), perm.end(), rng); + for (size_type ii = 0; ii != c_pool_size; ++ii) + m_ind[i*c_pool_size + ii] = int_buffer[perm[ii]]; + rand_float_range(hists, i*c_pool_size, (i+1)*c_pool_size, rng); + } + + if (small) { // cloned and small + + size_type k = 0; + for (size_type i = 0; i != n_masters; ++i) + for (size_type ii = 0; ii != c_pool_size; ++ii, ++k) + ind_nz[k] = std::make_pair(m_ind[k], &hists[k]); + + } else { // cloned, not small + + // unroll positions of sampling bits + // grab them here so that the calls to the rng are in the same + // order as Python... + size_type k = 0; + for (size_type c = 0; c != c_field_size; ++c) { + + size_type ii_start = cl_map[c] * c_pool_size; + size_type ii_end = ii_start + c_pool_size; + + for (size_type ii = ii_start; ii != ii_end; ++ii) + ind_nz[k++] = std::make_pair(from_rf(c, m_ind[ii]), &hists[ii]); + } + + } // end clone and not small + + } else { // initialization when not cloning, in constructor + + size_type* rfs_p = &rfs[0]; + for (size_type c = 0; c != c_field_size; ++c) { + + int lb_height = *rfs_p++, ub_height = *rfs_p++; + int lb_width = *rfs_p++, ub_width = *rfs_p++; + + size_type k = 0; + for (int y = lb_height; y != ub_height; ++y) + for (int x = lb_width; x != ub_width; ++x) + int_buffer[k++] = y * input_width + x; + + std::random_shuffle(perm.begin(), perm.end(), rng); + + size_type ii_start = c * c_pool_size; + size_type ii_end = ii_start + c_pool_size; + + for (size_type ii = ii_start; ii != ii_end; ++ii) { + NTA_ASSERT(ii - ii_start < perm.size()); + NTA_ASSERT(perm[ii - ii_start] < int_buffer.size()); + size_type pos_in_input = int_buffer[perm[ii - ii_start]]; + NTA_ASSERT(pos_in_input < input_size); + ind_nz[ii] = std::make_pair(pos_in_input, &hists[ii]); + } + + rand_float_range(hists, ii_start, ii_end, rng); + } + } + + return; + } // end initialization in constructor + + //---------------------------------------- + // Initialization with indnz, in load + //---------------------------------------- + + if (isCloned()) { // cloned + + size_type k = 0; + + for (size_type c = 0; c != indNZNRows(); ++c) { + + size_type ii_start = (!small ? cl_map[c] : c) * c_pool_size; + size_type ii_end = ii_start + c_pool_size; + + for (size_type ii = ii_start; ii != ii_end; ++ii) { + size_type pos_in_rf = indnz[2*ii]; + size_type pos_in_input = !small ? from_rf(c, pos_in_rf) : pos_in_rf; + value_type* ptr = &hists[0] + indnz[2*ii+1]; + ind_nz[k++] = std::make_pair(pos_in_input, ptr); + } + } + + } else { // initialization when not cloning, in load + + for (size_type c = 0; c != c_field_size; ++c) { + + size_type ii_start = c * c_pool_size; + size_type ii_end = ii_start + c_pool_size; + + for (size_type ii = ii_start; ii != ii_end; ++ii) + ind_nz[ii] = std::make_pair(indnz[2*ii], &hists[0] + indnz[2*ii+1]); + } + } + } + + public: + //-------------------------------------------------------------------------------- + /** + * Null constructor for persistence in Python. + */ + inline FDRCSpatial() {} + + //-------------------------------------------------------------------------------- + inline ~FDRCSpatial() {} + + //-------------------------------------------------------------------------------- + /** + * This version tag is used in persistence. + */ + inline const std::string version() const { return "fdrcsp_2.0"; } + + //-------------------------------------------------------------------------------- + /** + * Various accessors. + */ + inline bool isCloned() const { return clone_height > 0; } + inline size_type getNMasters() const { return n_masters; } + inline size_type getNColumns() const { return c_field_size; } + inline size_type getInputSize() const { return input_size; } + inline size_type getRFSide() const { return c_rf_side; } + inline size_type getBitPoolSizePerCoincidence() const { return c_pool_size; } + inline size_type getNSamplingBitsPerCoincidence() const { return c_nnz; } + inline size_type getInhibitionRadius() const + { return inhibition.getInhibitionRadius(); } + inline size_type getStimulusThresholdForLearning() const + { return stimulus_threshold_learning; } + inline size_type getStimulusThresholdForInference() const + { return stimulus_threshold_inference; } + inline value_type getHistogramThreshold() const { return histogram_threshold; } + inline value_type getNormalizationSum() const { return normalization_sum; } + + inline std::pair getInputShape() const + { + return std::make_pair(input_height, input_width); + } + + inline std::pair getCoincidenceFieldShape() const + { + return std::make_pair(c_height, c_width); + } + + inline std::pair getCloningShape() const + { + return std::make_pair(clone_height, clone_width); + } + + //-------------------------------------------------------------------------------- + inline size_t n_bytes() const + { + size_t n = 64 * sizeof(size_type); + n += nupic::n_bytes(ind_nz) + nupic::n_bytes(hists); + n += nupic::n_bytes(cl_map) + nupic::n_bytes(inv_cl_map); + n += inhibition.n_bytes(); + n += nupic::n_bytes(int_buffer); + n += nupic::n_bytes(d_output); + n += nupic::n_bytes(yy); + n += nupic::n_bytes(t_ind); + n += nupic::n_bytes(rfs); + return n; + } + + //-------------------------------------------------------------------------------- + inline bool is_small() const { return small; } + + //-------------------------------------------------------------------------------- + inline void print_size_stats(bool estimate=false) const + { + if (estimate) { + + cout << "Estimated" << endl; + cout << "nc =", c_field_size, endl; + cout << "pool =", c_pool_size, endl; + cout << "ind_nz =", (c_field_size * c_pool_size * sizeof(IndNZ)), endl; + cout << "hists =",(n_masters * c_pool_size * sizeof(value_type)), endl; + cout << "maps =", (2 * c_field_size * sizeof(size_type)), endl; + size_type ir = inhibition.getInhibitionRadius(); + size_type m = (2*ir+1)*(2*ir+1); + cout << "inhib =", (c_field_size * (16 + m * sizeof(size_type))), endl; + cout << "rfs =", (4 * c_field_size * sizeof(size_type)), endl; + + } else { + + size_type n = 64 * sizeof(size_type); + n += nupic::n_bytes(d_output); + n += nupic::n_bytes(yy); + + cout << + " nc =", c_field_size, endl, + "pool =", c_pool_size, endl, + "small =", (small ? "yes" : "no"), endl, + "ind_nz =", nupic::n_bytes(ind_nz), endl, + "hists =", nupic::n_bytes(hists), endl, + "maps =", (nupic::n_bytes(cl_map) + nupic::n_bytes(inv_cl_map)), endl, + "inhib =", inhibition.n_bytes(), endl, + "rfs =", nupic::n_bytes(rfs), endl, + "t_ind =", nupic::n_bytes(t_ind), endl, + "int buffer =", nupic::n_bytes(int_buffer), endl, + "other =", n, endl, + "total =", n_bytes(), endl; + } + } + + //-------------------------------------------------------------------------------- + // TODO: the estimate doesn't seem to be too accurate ?? + // but IndNZ is the quadratic term that leads the asymptote + inline size_type estimate_max_size_bytes() const + { + size_type n = 64 * sizeof(size_type); + n += c_field_size * c_pool_size * sizeof(IndNZ); // ind_nz + n += n_masters * c_pool_size * sizeof(value_type); // hists + n += 2 * c_field_size * sizeof(size_type); // maps + size_type ir = inhibition.getInhibitionRadius(); + size_type m = (2*ir+1)*(2*ir+1); + n += c_field_size * (16 + m * sizeof(size_type)); // inhibition_area + n += 4 * c_field_size * sizeof(size_type); // rfs + n += std::max(c_rf_size, c_field_size) * sizeof(size_type); // int_buffer + n += input_size * c_nnz * sizeof(size_type*); // t_ind + n += input_size * sizeof(size_type); + n += c_field_size * sizeof(size_type); + return n; + } + + //-------------------------------------------------------------------------------- + inline void reset() {} + + //-------------------------------------------------------------------------------- + /** + * For inspectors. + * This makes compute slower. + */ + inline void setStoreDenseOutput(bool x) + { + d_output.resize(x * getNColumns()); + } + + //-------------------------------------------------------------------------------- + /** + * For inspectors, only if setStoreDenseOutput(true) was called before! + */ + template + inline void get_dense_output(It beg) const + { + NTA_ASSERT(!d_output.empty()); + + for (size_type i = 0; i != getNColumns(); ++i) + *beg++ = d_output[i]; + } + + //-------------------------------------------------------------------------------- + /** + * Get the coincidences and histogram counts, either whole, or just the learnt + * part. + * For debugging and testing only, SLOW. + * Doesn't work in nupic2. + */ + inline SparseMatrix + cm(bool withCounts =true, bool learnt =false) const + { + SparseMatrix m(c_field_size, input_size); + + for (size_type i = 0; i != c_field_size; ++i) { + size_type beg = (small ? cl_map[i] : i) * c_pool_size; + size_type end = learnt ? beg + c_nnz : beg + c_pool_size; + for (size_type j = beg; j != end; ++j) { + value_type count = withCounts ? *(ind_nz[j].second) : 1; + size_type pos_in_input = small ? from_rf(i, ind_nz[j].first) : ind_nz[j].first; + m.set(i, pos_in_input, count); + } + } + + return m; + } + + //-------------------------------------------------------------------------------- + /* + * Doesn't work in nupic2. + */ + inline SparseMatrix cm_t() const + { + SparseMatrix m(c_field_size, input_size); + + for (size_type j = 0; j != input_size; ++j) + for (size_type k = 0; k != t_ind[j].size(); ++k) + m.set(t_ind[j][k] - & yy[0], j, 1); + + return m; + } + + //-------------------------------------------------------------------------------- + /** + * Return a single row of the coincidence matrix, as a sparse vector. + * The vector has unsorted indices. + * First requested for inspectors. + */ + template + inline void + get_cm_row_sparse(size_type row, It1 begin_ind, It2 begin_nz, bool learnt =false) const + { + size_type j_start = (small ? cl_map[row] : row) * c_pool_size; + size_type j_end = learnt ? j_start + c_nnz : j_start + c_pool_size; + + for (size_type j = j_start; j != j_end; ++j) { + *begin_ind++ = small ? from_rf(row, ind_nz[j].first) : ind_nz[j].first; + *begin_nz++ = *(ind_nz[j].second); + } + } + + //-------------------------------------------------------------------------------- + template + inline void getMasterLearnedCoincidence(size_type m, It1 rows, It2 cols) + { + NTA_ASSERT(m < n_masters); + + size_type c = (isCloned() && !small) ? inv_cl_map[m][0] : m; + const IndNZ* p = row_begin(c); + + if (!small) + for (size_type i = 0; i != c_nnz; ++i) + to_rf(c, p[i].first, cols[i], rows[i]); + else + for (size_type i = 0; i != c_nnz; ++i) { + cols[i] = p[i].first % c_rf_side; + rows[i] = p[i].first / c_rf_side; + } + } + + //-------------------------------------------------------------------------------- + template + inline void getMasterHistogram(size_type m, It1 rows, It1 cols, It2 values) + { + NTA_ASSERT(m < n_masters); + + size_type c = (isCloned() && !small) ? inv_cl_map[m][0] : m; + const IndNZ* p = row_begin(c); + + if (!small) + for (size_type i = 0; i != c_pool_size; ++i) { + to_rf(c, p[i].first, cols[i], rows[i]); + values[i] = *p[i].second; + } + else + for (size_type i = 0; i != c_pool_size; ++i) { + cols[i] = p[i].first % c_rf_side; + rows[i] = p[i].first / c_rf_side; + values[i] = *p[i].second; + } + } + + //-------------------------------------------------------------------------------- + private: + /** + * Assumes active coincidences are listed in int_buffer. Doesn't modify int_buffer. + */ + template + inline void learn(It x) + { + greater_2nd_p order; + + // this changes the master histograms repeatedly + if (small) { + + for (size_type i = 0; i != n_active; ++i) { + + size_type c = int_buffer[i]; + IndNZ *beg = row_begin(cl_map[c]); + IndNZ *end = beg + c_pool_size; + + for (IndNZ* p = beg; p != end; ++p) + *(p->second) += x[from_rf(c, p->first)]; + } + + } else { // not small + + for (size_type i = 0; i != n_active; ++i) { + + IndNZ *beg = row_begin(int_buffer[i]); + IndNZ *end = beg + c_pool_size; + + for (IndNZ* p = beg; p != end; ++p) + *(p->second) += x[p->first]; + } + } // end not small case + + // now we can normlize the master histograms that were + // touched, one by one, but each only once! (several + // active coincidences might point to the same master + // histogram) + if (isCloned()) { + + std::set touched_masters; + + if (small) { + + for (size_type i = 0; i != n_active; ++i) { + + // to make sure we don't normalize the same master + // histogram twice + size_type c = int_buffer[i]; + size_type master_index = cl_map[c]; + + if (not_in(master_index, touched_masters)) { + normalizeHistogram(master_index); + touched_masters.insert(master_index); + } + } + + // and resort touched master + set::const_iterator it = touched_masters.begin(); + + for (; it != touched_masters.end(); ++it) { + IndNZ *beg = row_begin(*it); + IndNZ *end = beg + c_pool_size; + std::partial_sort(beg, beg + c_nnz, end, order); + } + + } else { // not small + + for (size_type i = 0; i != n_active; ++i) { + + // to make sure we don't normalize the same master + // histogram twice + size_type master_index = cl_map[int_buffer[i]]; + + if (not_in(master_index, touched_masters)) { + normalizeHistogram(master_index); + touched_masters.insert(master_index); + } + } + + // finally, resort all the touched coincidences + // This step can re-order coincidences that were not touched, because + // they share a master with a coincidence that was touched! + std::vector prev(c_pool_size); + set::const_iterator it = touched_masters.begin(); + + for (; it != touched_masters.end(); ++it) { + + const std::vector& clones = inv_cl_map[*it]; + IndNZ *beg = row_begin(clones[0]), *end = beg + c_pool_size; + + std::copy(beg, end, prev.begin()); + + std::partial_sort(beg, beg + c_nnz, end, order); + + std::vector a, b; + + for (size_type i = 0; i != c_nnz; ++i) { + size_type idx = prev[i].first; + bool changed_side = true; + for (size_type j = 0; j != c_nnz; ++j) + if (beg[j].first == idx) { + changed_side = false; + break; + } + if (changed_side) { + a.push_back(i); + } + } + + for (size_type i = c_nnz; i != c_pool_size; ++i) { + size_type idx = prev[i].first; + bool changed_side = false; + for (size_type j = 0; j != c_nnz; ++j) + if (beg[j].first == idx) { + changed_side = true; + break; + } + if (changed_side) { + b.push_back(i); + } + } + + std::copy(prev.begin(), prev.end(), beg); + + if (!a.empty()) { + for (size_type j = 0; j != clones.size(); ++j) { + IndNZ *beg = row_begin(clones[j]); + for (size_type k = 0; k != a.size(); ++k) + std::swap(beg[a[k]], beg[b[k]]); + } + } + } + } + + } else { + + for (size_type i = 0; i != n_active; ++i) { + + size_type active = int_buffer[i]; + normalizeHistogram(active); + + IndNZ *beg = row_begin(active), *end = beg + c_pool_size; + std::partial_sort(beg, beg + c_nnz, end, order); + } + } + } + + //-------------------------------------------------------------------------------- + /** + * The infer() method takes input vectors and produces output vectors that best + * "represent" the input w.r.t. to the matrix of coincidences. The input, output + * and coincidences are all sparse binary (0/1) vectors. The non-zeros of the output + * correspond to the coincidences that best match the input vector. The output + * always has constant sparsity (constant number of non-zeros = density), + * according to FDR principles. The infer method has 2 parts, and optionally + * calls update() to update the coincidences (if learning is on). + * + * This method takes in the input vector x and produces the result vector y which + * the output of the SP itself. The input is a binary 0/1 vector of size input_width + * (the size of the coincidences), and the output is another binary 0/1 vector, + * of size input_height (the number of coincidences). + * + * 1. Compute matches: + * ================== + * This step computes the number of overlapping bits between the input and each + * coincidence. This is achieved as follows: + * Multiply current sparse matrix (in ind_nz) by x on the right, place result into + * y. When doing that multiplication, for row i, we multiply up to ub[i] non-zeros + * only: if we are not doing learning, ub[i] == c_nnz (set in constructor) ; if we are + * learning, ub[i] gets adjusted in update() to the number of non-zeros whose values + * are > threshold. The order of the non-zeros doesn't matter here, except maybe to + * optimize cache usage (try sorting them in increasing order before ub[i]). While + * performing the right vec prod, we also count the number of matches that are + * greater than stimulus_threshold (n_gt). + * + * 2. Impose constant sparsity on outputs: + * ====================================== + * This step selects the top_n coincidences that best match x (highest number of + * overlapping bits), sets the corresponding bits of y to 1, and the others to + * 0 (inhibition). Before we set the bits of y to 0/1, we trigger learning with + * y's top_n first elements containing the indices of the non-zeros we will set + * in y, if doLearn is true. Finally, in_place_sparse_to_dense_01 expands y in + * place, from a vector of top_n indices to a binary 0/1 vector having 1's at + * the positions of the top_n indices only, and 0's elsewhere. + * + * The update() method maintains the counts of the on bits of each coincidence, if + * learning is turned on: the bits that match with the inputs more are reinforced + * and the others are gradually ignored. The update() method has 3 parts. + * + * This method takes in a vector of the indices of the active coincidences, and + * the input vector (needed to compute the overlap with each coincidence and + * increment the bit counters accordingly). + * + * 1. Increment coincidence bit counts: + * =================================== + * For the active coincidences only, we increment the counts of the bits that match + * between the coincidence and x. This will increase the likelihood that "useful" + * bits get promoted for each coincidence, while the bits that don't match enough + * will be made irrelevant. For the purpose of incrementing the counts, we need to + * consider _all_ the non-zeros of each active coincidence, not only the non-zeros + * up to ub[i], since we want the set of "important" bits to be dynamic: new + * "important" bits can enter the set at any point, depending on the statistics + * of the inputs. + * + * 3. Normalize, infrequently: + * ========================== + * Once in a while, we normalize, which has the effect of pushing some coincidence + * bits below the threshold, making them irrelevant for further inferences. This + * operations is done only infrequently because it takes too much time to be done + * on each input vector. It can be thought of as an "inhibition", the more + * relevant bits "inhibiting" those that don't match the inputs often enough. The + * whole row is normalized, including the bits that are 'less relevant' (after + * ub[i]). We normalize *ALL* rows, so that we also normalize rows that were + * updated in between the points at which we normalize (we normalize only every + * 10 steps, for example, but we we update rows on each iteration). + * + * 2. Segregate nz above/below threshold: + * ===================================== + * We update ub[i] for each active row i by sorting the whole row + * and then finding the new ub[i]. Non-zeros with a count above threshold are + * stored before ub[i], and the others after. Note that to segregate correctly, + * we need to take into account both the non-zeros that are currently *above* + * and *below* threshold: depending on the statistics of the input, those two + * sets can change from iteration to iteration. Which means we need to sort + * and threshold on each iteration, *AFTER* incrementing the counts and normalizing + * them. + * + * Parameters: + * ========== + * - babyIdx: index of the baby that should compute on this call + * - x..x_end: input vector (input to the SP) + * - y..y_end: output vector (output of the SP) + * - doLearn: whether to learn or not + * - doInfer: whether to do inference or not + * + * IMPLEMENTATION NOTES: + * 1. If less than stimulus_threshold bits on in x, no coincidence + * will match properly, so we can return the null vector right + * away. + * + * 2. We use n_gt with two different meanings in this function: first, + * it counts the number of on bits in x. Then we reuse it to mean the + * number of coincidences that match x above stimulus_threshold. + * + * 3. To compute the right vec prod (that computes the overlap between the + * coincidences and the input vector) in 1. (hotspot), the loop "jumps over" + * by increments of two, because the coincidences are stored as vector of + * pair(index,counter value), and we need only the indices here. This is much + * faster than iterating on each pair, and dereferencing with pair.first. + */ + public: + template + inline void compute(It1 x, It1 x_end, It2 y, It2 y_end, + bool doLearn =false, bool doInfer =true) + { + { // Pre-conditions + NTA_ASSERT((size_type)(x_end - x) == getInputSize()); + NTA_ASSERT((size_type)(y_end - y) == getNColumns()); + } // End pre-conditions + + size_type count = 0; + + size_type stimulus_threshold = doLearn ? stimulus_threshold_learning + : stimulus_threshold_inference; + + for (It1 x_it = x; x_it != x_end && count <= stimulus_threshold; ++x_it) + count += *x_it != 0; + + if (count <= stimulus_threshold) { + std::fill(y, y_end, 0); + return; + } + + // use DirectAccess and multicolor board if this is slow, + // to amortize the actual setting to 0 + set_to_zero(yy); + + if (t_ind.empty() && doInfer) { + transpose(); + inhibition.setDesiredOutputDensity(desired_density_inference); + } else if (!t_ind.empty() && doLearn) { + t_ind.resize(0); + inhibition.setDesiredOutputDensity(desired_density_learning); + } + + // TODO: test that indices would be as fast as pointers + // and replace pointers to avoid pointer size issues on 64-bits + // platforms + // TODO: combine transposition and inference, so + // the transpose product works in learning too + // TODO: can we compute on the transpose without computing + // the transpose? + // TODO: have the pointers in the transpose land on y directly + // without indirection + if (t_ind.empty()) { + + if (small) { + + for (size_type i = 0; i != c_field_size; ++i) { + + size_type m = cl_map[i]; + value_type s = 0.0f; + size_type *p = &ind_nz[m * c_pool_size].first; + size_type *p_end = p + P_INC * c_nnz; + + for (; p != p_end; p += P_INC) + s += x[from_rf(i, *p)]; + + yy[i] = s; + } + + } else { // not small, faster + + for (size_type i = 0; i != c_field_size; ++i) { + + // *** HOTSPOT *** ?? + value_type s = 0.0f; + size_type *p = &ind_nz[i * c_pool_size].first; + size_type *p_end = p + P_INC * c_nnz; + + for (; p != p_end; p += P_INC) + s += x[*p]; + + yy[i] = s; + } + } + + } else { + + for (It1 it_x = x; it_x != x_end; ++it_x) { + if (*it_x != 0) { + size_type c = (size_type) (it_x - x); + value_type **j = & t_ind[c][0]; + value_type **j_end = j + t_ind[c].size(); + for (; j != j_end; ++j) + **j += *it_x; + } + } + } + + if (!d_output.empty()) + std::copy(yy.begin(), yy.end(), d_output.begin()); + + // 2. Impose constant output sparsity + // puts results in int_buffer + n_active = inhibition.compute(yy.begin(), &int_buffer[0], + stimulus_threshold, + doLearn ? convolution_k_learning + : convolution_k_inference); + + if (doLearn && 0 < n_active) + // looks at int_buffer, but doesn't modify it + learn(x); + + to_dense_01(n_active, int_buffer, y, y_end); + } + + public: + //-------------------------------------------------------------------------------- + // PERSISTENCE + //-------------------------------------------------------------------------------- + /** + * This methods to pickle/unpickle a FDRCSpatial. + */ + inline size_type persistent_size() const + { + std::stringstream buff; + save(buff); + return buff.str().size(); + } + + //-------------------------------------------------------------------------------- + inline void save(std::ostream& out_stream) const + { + { + NTA_ASSERT(out_stream.good()); + } + + out_stream << version() << ' ' + << (t_ind.empty() ? "0 " : "1 ") + << (int) small << ' ' + << rng << ' ' + << input_height << ' ' << input_width << ' ' + << c_height << ' ' << c_width << ' ' + << c_rf_radius << ' ' << c_pool_size << ' ' << c_nnz << ' ' + << c_rf_side << ' ' << c_rf_size << ' ' + << clone_height << ' ' << clone_width << ' ' + << inhibition.getSmall() << ' ' + << desired_density_learning << ' ' + << desired_density_inference << ' ' + << stimulus_threshold_learning << ' ' + << stimulus_threshold_inference << ' ' + << convolution_k_learning << ' ' + << convolution_k_inference << ' ' + << histogram_threshold << ' ' + << normalization_sum << ' ' + << hists << ' ' + << n_active << ' ' + << d_output.size() << ' '; + + size_type n = isCloned() ? n_masters : c_field_size; + + for (size_type i = 0; i != n; ++i) { + + size_type c = (isCloned() && !small) ? inv_cl_map[i][0] : i; + const IndNZ* p = row_begin(c); + + for (size_type j = 0; j != c_pool_size; ++j) { + + size_type pos_in_input = p[j].first; + size_type pos_in_rf = pos_in_input; + + if (isCloned() && !small) + to_rf(c, pos_in_input, pos_in_rf); + + out_stream << pos_in_rf << " " + << (p[j].second - &hists[0]) + << " "; + } + } + } + + //-------------------------------------------------------------------------------- + inline void load(std::istream& in_stream) + { + { + NTA_ASSERT(in_stream.good()); + } + + std::string ver; + in_stream >> ver; + + if (ver != version()) { + std::cout << "Incompatible version for fdr c sp: " << ver + << " - needs: " << version() << std::endl; + exit(-1); + } + + int dos = 0; + int learn_infer_flag = 0; + int is_small = 0; + int small_inhibition = 0; + + in_stream >> learn_infer_flag >> is_small >> rng + >> input_height >> input_width + >> c_height >> c_width + >> c_rf_radius >> c_pool_size >> c_nnz + >> c_rf_side >> c_rf_size + >> clone_height >> clone_width + >> small_inhibition + >> desired_density_learning + >> desired_density_inference + >> stimulus_threshold_learning + >> stimulus_threshold_inference + >> convolution_k_learning + >> convolution_k_inference + >> histogram_threshold + >> normalization_sum + >> hists + >> n_active + >> dos; + + NTA_ASSERT(is_small == 0 || is_small == 1); + small = (bool) is_small; + input_size = input_height * input_width; + c_field_size = c_height * c_width; + n_masters = clone_height > 0 ? clone_height * clone_width : c_field_size; + int_buffer.resize(std::max(c_field_size, c_rf_size), 0); + + std::vector indnz; + size_type n = isCloned() ? n_masters : c_field_size; + indnz.resize(2 * n * c_pool_size); + + for (size_type i = 0; i != indnz.size(); ++i) + in_stream >> indnz[i]; + + initialize_cl_maps(); + initialize_rfs(); + initialize_ind_nz(&indnz[0]); // needs rfs and cl_maps + inhibition.initialize(c_height, c_width, + learn_infer_flag == 0 ? desired_density_learning + : desired_density_inference, small_inhibition); + + d_output.resize(dos); + + yy.resize(getNColumns()); + if (learn_infer_flag == 1) + transpose(); + + { // Post-conditions + NTA_ASSERT(!(isCloned() == false && small == true)); + NTA_ASSERT((clone_height == 0 && clone_width == 0) + || clone_height * clone_width != 0); + NTA_ASSERT((small && ind_nz.size() == n_masters * c_pool_size) + || (!small && ind_nz.size() == c_field_size * c_pool_size)); + NTA_ASSERT(c_nnz <= c_pool_size); + NTA_ASSERT(c_pool_size <= (2 * c_rf_radius + 1) * (2 * c_rf_radius + 1)); + NTA_ASSERT(0 < histogram_threshold); + NTA_ASSERT(0 < normalization_sum); + } // End post-conditions + } + + private: + //-------------------------------------------------------------------------------- + // If small, ind_nz stores only masters, otherwise it stores the full coincidences. + inline size_type indNZNRows() const + { + return small ? n_masters : c_field_size; + } + + //-------------------------------------------------------------------------------- + /** + * Returns a pointer to the first (index,value) pair of row i. + */ + inline IndNZ* row_begin(size_type i) + { + return &ind_nz[0] + i * c_pool_size; + } + + //-------------------------------------------------------------------------------- + /** + * Returns a pointer to the first (index,value) pair of row i. + */ + inline const IndNZ* row_begin(size_type i) const + { + return &ind_nz[0] + i * c_pool_size; + } + + //-------------------------------------------------------------------------------- + /** KEEP: if not storing the clone map, this will give the master index for + any coincidence index + */ + inline size_type getMasterIndex(size_type row_index) const + { + return (row_begin(row_index)->second - &hists[0]) / c_pool_size; + } + + //-------------------------------------------------------------------------------- + inline void + to_rf(size_type c, size_type pos_in_input, + size_type& x_in_rf, size_type& y_in_rf, size_type& pos_in_rf) const + { + NTA_ASSERT(c < c_field_size); + NTA_ASSERT(pos_in_input < input_size); + + size_type lb_height = rfs[4*c]; + size_type lb_width = rfs[4*c+2]; + size_type x_in_input = pos_in_input % input_width; + size_type y_in_input = pos_in_input / input_width; + x_in_rf = x_in_input - lb_width; + y_in_rf = y_in_input - lb_height; + pos_in_rf = y_in_rf * c_rf_side + x_in_rf; + + NTA_ASSERT(x_in_rf < c_rf_side); + NTA_ASSERT(y_in_rf < c_rf_side); + NTA_ASSERT(pos_in_rf < c_rf_size); + } + + //-------------------------------------------------------------------------------- + inline void + to_rf(size_type c, size_type pos_in_input, size_type& pos_in_rf) const + { + size_type x_in_rf = 0, y_in_rf = 0; + to_rf(c, pos_in_input, x_in_rf, y_in_rf, pos_in_rf); + } + + //-------------------------------------------------------------------------------- + inline void + to_rf(size_type c, size_type pos_in_input, size_type& x_in_rf, size_type& y_in_rf) const + { + size_type pos_in_rf = 0; + to_rf(c, pos_in_input, x_in_rf, y_in_rf, pos_in_rf); + } + + //-------------------------------------------------------------------------------- + inline void + from_rf(size_type c, size_type pos_in_rf, + size_type& x_in_input, size_type& y_in_input, size_type& pos_in_input) const + { + NTA_ASSERT(c < c_field_size); + NTA_ASSERT(pos_in_rf < c_rf_size); + + size_type lb_height = rfs[4*c]; + size_type lb_width = rfs[4*c+2]; + size_type x_in_rf = pos_in_rf % c_rf_side; + size_type y_in_rf = pos_in_rf / c_rf_side; + x_in_input = x_in_rf + lb_width; + y_in_input = y_in_rf + lb_height; + pos_in_input = y_in_input * input_width + x_in_input; + + NTA_ASSERT(x_in_input < input_width); + NTA_ASSERT(y_in_input < input_height); + NTA_ASSERT(pos_in_input < input_size); + } + + //-------------------------------------------------------------------------------- + inline size_type from_rf(size_type c, size_type pos_in_rf) const + { + size_type x, y, pos_in_input; + from_rf(c, pos_in_rf, x, y, pos_in_input); + return pos_in_input; + } + + //-------------------------------------------------------------------------------- + /** + * Normalize one histogram. + */ + inline void normalizeHistogram(size_type i) + { + { + NTA_ASSERT((isCloned() && i < getNMasters()) || i < getNColumns()); + } + + value_type* beg = &hists[0] + i * c_pool_size; + value_type* end = beg + c_pool_size; + value_type s = 1e-9f; + + for (value_type *p = beg; p != end; ++p) + s += *p; + + value_type k = normalization_sum / s; + + for (value_type* p = beg; p != end; ++p) + *p *= k; + } + + //-------------------------------------------------------------------------------- + /** + * Normalize all the histograms. + */ + inline void normalize() + { + size_t n = isCloned() ? getNMasters() : getNColumns(); + + for (size_type i = 0; i != n; ++i) + normalizeHistogram(i); + } + + //-------------------------------------------------------------------------------- + inline void transpose() + { + // TODO: maintain the transpose incrementally when doing the swaps + // TODO: transpose only up to first c_nnz positions, or keep + // whole transpose so we can use it in learning too?? + // TODO: interleave t_start and t_nnz for improved locality? + // TODO: reduce type size to fit better in cache + // TODO: speed-up by allocating columns in dense?? + // TODO: remove either t_start or t_nnzc, set up more pointers + // for inference + + // if small, change sizes + t_ind.resize(getInputSize()); + + for (size_type i = 0; i != t_ind.size(); ++i) + t_ind[i].clear(); + + for (size_type i = 0; i != c_field_size; ++i) { + size_type j = (small ? cl_map[i] : i) * c_pool_size; + size_type j_end = j + c_nnz; + for (; j != j_end; ++j) { + size_type pos_in_input = + small ? from_rf(i, ind_nz[j].first) : ind_nz[j].first; + t_ind[pos_in_input].push_back(& yy[0] + i); + } + } + } + + //-------------------------------------------------------------------------------- + nupic::Random rng; + + size_type input_size, input_height, input_width; + size_type c_height, c_width, c_field_size, c_rf_radius, c_pool_size, c_nnz; + size_type c_rf_side, c_rf_size; + size_type n_masters, clone_height, clone_width; + value_type desired_density_learning; + value_type desired_density_inference; + size_type stimulus_threshold_learning; + size_type stimulus_threshold_inference; + value_type convolution_k_learning; + value_type convolution_k_inference; + value_type histogram_threshold; + value_type normalization_sum; + + size_type n_active; + bool small; + std::vector ind_nz; // vectors of pairs + std::vector hists; + std::vector cl_map; + std::vector > inv_cl_map; + std::vector int_buffer; + std::vector d_output; + Inhibition inhibition; + + std::vector yy; + std::vector > t_ind; + + std::vector rfs; + }; + + //-------------------------------------------------------------------------------- + } // end namespace algorithms +} // end namespace nupic + +#endif // NTA_FDR_C_SPATIAL_HPP diff --git a/src/nupic/algorithms/FDRSpatial.hpp b/src/nupic/algorithms/FDRSpatial.hpp new file mode 100644 index 0000000000..4e102657cd --- /dev/null +++ b/src/nupic/algorithms/FDRSpatial.hpp @@ -0,0 +1,1000 @@ +/* --------------------------------------------------------------------- + * Numenta Platform for Intelligent Computing (NuPIC) + * Copyright (C) 2013, Numenta, Inc. Unless you have an agreement + * with Numenta, Inc., for a separate license for this software code, the + * following terms and conditions apply: + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses. + * + * http://numenta.org/licenses/ + * --------------------------------------------------------------------- + */ + +#ifndef NTA_FDR_SPATIAL_HPP +#define NTA_FDR_SPATIAL_HPP + +#include + +namespace nupic { + namespace algorithms { + + //-------------------------------------------------------------------------------- + /** + * The sweeping algorithm of the continuous spatial pooler. + */ + template + inline void csp_sweep(I c_field_x, I c_field_y, + I stimulusThreshold, + I inhibitionRadius, + It denseOutput, It denseOutput_end, + std::vector& activeElements, + It afterInhibition, It afterInhibition_end) + { + NTA_ASSERT(denseOutput <= denseOutput_end); + + const I n_c = c_field_x * c_field_y; + typedef greater_2nd_no_ties Order; + std::set, Order> to_visit; + std::vector > visited(n_c, std::make_pair(-1,-1)); + + std::fill(afterInhibition, afterInhibition_end, (nupic::Real32)0); + + for (I i = 0; i != n_c; ++i) + if (denseOutput[i] > stimulusThreshold) { + to_visit.insert(std::make_pair(i, denseOutput[i])); + visited[i] = std::make_pair(i, denseOutput[i]); + } + + activeElements.clear(); + + while (! to_visit.empty()) { + + I chosen = to_visit.begin()->first; + activeElements.push_back(chosen); + + I cx = chosen / c_field_y; + I cy = chosen % c_field_y; + I xmin = (I) std::max((int)0, (int)cx - (int)inhibitionRadius); + I xmax = std::min(cx + inhibitionRadius+1, c_field_x); + I ymin = (I) std::max((int)0, (int)cy - (int)inhibitionRadius); + I ymax = std::min(cy + inhibitionRadius+1, c_field_y); + + //std::cout << "Chose: " << chosen + // << " with val: " << to_visit.begin()->second + //<< " at " << cx << "," << cy + // << std::endl; + //std::cout << "xmin= " << xmin << " xmax= " << xmax + // << " ymin= " << ymin << " ymax= " << ymax + // << std::endl; + + //std::cout << "inhibiting: "; + + for (I x = xmin; x != xmax; ++x) + for (I y = ymin; y != ymax; ++y) { + I ii = x * c_field_y + y; + if (visited[ii].first != -1) { + //std::cout << "(" << x << "," << y << "," << ii << ")"; + to_visit.erase(visited[ii]); + visited[ii].first = -1; + } + } + //std::cout << std::endl; + + afterInhibition[chosen] = 1; + } + } + + //-------------------------------------------------------------------------------- + /** + * The FDRSpatial class stores binary 0/1 coincidences and computes the degree + * of match between an input vector (binary 0/1) and each coincidence, to output + * a sparse (binary 0/1) "representation" of the input vector in terms of the + * coincidences. The degree of match is simply the number of bits that overlap + * between each coincidence and the input vector. Only the top-N best matches are + * turned on in the output, and the outputs always have the same, fixed number + * of bits turned on (N), according to FDR principles. + * + * The coincidences can be learnt, in which case the non-zeros of the coincidences + * that match the inputs best are reinforced while others are gradually forgotten. + * Learning is online and the coincidences can adapt to the changing statistics + * of the inputs. + * + * NOTE: + * there are two thresholds used in this class: + * - stimulus_threshold is used to decide whether a coincidence matches the + * input vector well enough or not. It is a hurdle that the coincidence has + * to pass in order to participate in the representation of the input, removing + * coincidences that would have only an insignificant number of bits matching + * the input. + * - histogram_threshold is used, with learning only, to decide which bits from + * the coincidences are more important and can participate in matching the + * input. Bits with a count lower than histogram_threshold are kept in the + * coincidence, but they do not participate to match the input. + * + * IMPLEMENTATION NOTE: + * Each row (coincidence) has exactly nnzpr non-zeros. + * The non-zeros are represented by pairs (index,count) of type (uint,float), + * and we call that type 'IndNZ'. Since all the rows have the same number of + * non-zeros, we use a compact storage where all the non-zeros are stored in + * a vector (of immutable size = nrows * nnzpr), and this vector is called + * 'ind_nz'. The k-th non-zero of row i is at position: ind_nz[i*nnzpr+k]. + * + * IMPLEMENTATION NOTE: + * In order to optimize speed, the non-zeros of each coincidence are stored in + * such a way that the non-zeros which have a count > histogram_threshold appear + * first, and the others after. The boundary between those two sets is maintained + * in ub[i] for each row i. These two sets are updated in update(). In infer(), + * only the non-zeros up to ub[i] are used to compute the match of coincidence i + * and the input vector. + * + * TODOS: + * ===== + * 1. Separate learning from inference (don't call update in infer), which is cleaner + * and we can call infer() without conditionally calling learn(). + * + * 2. Return only indices of the non-zeros from infer(), when integrating with FDR TP. + */ + class FDRSpatial + { + public: + typedef nupic::UInt32 size_type; + typedef nupic::Real32 value_type; + typedef std::pair IndNZ; + + typedef enum { uniform, gaussian } CoincidenceType; + + //-------------------------------------------------------------------------------- + /** + * Constructor for "discrete" SP. + * + * Creates a random sparse matrix with uniformly distributed non-zeros, all the + * non-zeros having value 1, unless _clone is true, in which case the coincidence + * matrix is not set here, but can be set later from a SM with set_cm. + * The coincidences are sparse 0/1 vectors (vertices of the unit hypercube of + * dimension ncols). + * + * Parameters: + * ========== + * - nbabies: the number of babies in this FDR SP + * - nrows: the number of coincidence vectors + * - ncols: the size of each coincidence vector (number of elements) + * - nnzpr: number of non-zeros per row, i.e. number of non-zeros in each + * binary coincidence + * - output_nnz: number of non-zeros in result vector for infer() ( <= nrows) + * - stimulus_threshold: minimum number of bits in the input that need to + * match with one coincidence for the input vector. If that threshold + * is not met by a pair (coincidence,input), the output for that + * coincidence is zero. + * - clone: whether to clone this spatial pooler or not. Two or more spatial + * poolers that are cloned share the same coincidences. + * - coincidence_type: the type of coincidence to use. The type determines + * the distribution of the non-zeros inside the coincidence. + * Available types: uniform, gaussian. If gaussian, specify rf_x + * and sigma. + * - rf_x: length of the receptive field in each coincidence in gaussian + * mode: > 0, ncols % rf_x == 0. + * - sigma: sigma for the gaussian distribution when using gaussian + * coincidences, > 0. + * - seed: random seed, that can be set to make runs repeatable. This seed + * influences only the initial random coincidence matrix. There is + * no randomness in the rest of the algorithm. + * - init_nz_val: initial value of the counts for each bit of each coincidence + * (used in learning) + * - threshold_cte: determines histogram threshold, that is, bit count that + * that needs to be exceeded for coincidence bit to participate + * in matching (see learning) + * - normalization_sum: value to which the sum of the bit counts for each + * coincidence is normalized to (reduces the likelihood of a + * coincidence bit to participate in further matching, see learning) + * - normalization_freq: how often normalization is performed + * - hysteresis: Must be >= 1.0. == 1.0 by default. If > 1.0, then outputs that + * were present in the sparse output of the previous time step will + * have their values multiplied by hysteresis before choosing the + * winners in the current time step. + * + * NOTE: + * FDRSpatial starts with learning off. + * + * IMPLEMENTATION NOTE: + * Don't forget to initialize ub to nnzpr for each row, so that we multiply + * correctly in infer when not using learning. + */ + FDRSpatial(size_type _nbabies, + size_type _nrows, size_type _ncols, size_type _nnzpr, + size_type _output_nnz, + size_type _stimulus_threshold, + bool _clone =false, + CoincidenceType coincidence_type =uniform, + size_type _rf_x =0, + value_type _sigma =0.0f, + int _seed =-1, + value_type _init_nz_val =1.0f, + value_type _threshold_cte =800.0f, + value_type _normalization_sum =1000.0f, + size_type _normalization_freq =20, + value_type _hysteresis =1.0f) + : nbabies(_nbabies), + nrows(_nrows), ncols(_ncols), nnzpr(_nnzpr), iter(0), + output_nnz(_output_nnz), + hysteresis(_hysteresis), + stimulus_threshold(_stimulus_threshold), + histogram_threshold((value_type) _threshold_cte / (value_type) nnzpr), + normalization_sum(_normalization_sum), + normalization_freq(_normalization_freq), + ub(nrows, nnzpr), ind_nz(nrows * nnzpr), + n_prev_winners(0), prev_winners(nrows, 0), + d_output(0) + { + { // Pre-conditions + NTA_ASSERT(0 < nnzpr && nnzpr <= ncols); + NTA_ASSERT(output_nnz <= nrows); + NTA_ASSERT(1.0 <= hysteresis); + NTA_ASSERT(0 < histogram_threshold); + NTA_ASSERT(0 < normalization_sum); + NTA_ASSERT(0 < normalization_freq); + NTA_ASSERT(ub.size() == nrows); + for (size_type i = 0; i != ub.size(); ++i) + NTA_ASSERT(ub[i] == nnzpr); + NTA_ASSERT(coincidence_type == uniform + || coincidence_type == gaussian); + NTA_ASSERT(coincidence_type != gaussian + || (_rf_x > 0 && _sigma > 0)); + } // End pre-conditions + + if (! _clone) { + + if (coincidence_type == uniform) + + random_pair_sample(nrows, ncols, nnzpr, ind_nz, _init_nz_val, _seed); + + else if (coincidence_type == gaussian) + + gaussian_2d_pair_sample(nrows, ncols, nnzpr, _rf_x, _sigma, ind_nz, + _init_nz_val, _seed); + + else { + std::cout << "Unknown coincidence type: " << coincidence_type + << " - exiting" << std::endl; + exit(-1); + } + + normalize(); + } + + { // Post-conditions + NTA_ASSERT(ind_nz.empty() || ind_nz.size() == nrows * nnzpr); + for (size_type i = 0; i != ind_nz.size(); ++i) + NTA_ASSERT(ind_nz[i].first < ncols); + } // End post-conditions + } + + //-------------------------------------------------------------------------------- + /** + * Null constructor for persistence in Python. + */ + inline FDRSpatial() {} + + //-------------------------------------------------------------------------------- + /** + * This version tag is used in persistence. + */ + inline const std::string version() const { return "fdrsp_1.0"; } + + //-------------------------------------------------------------------------------- + /** + * Various accessors. + */ + inline size_type nBabies() const { return nbabies; } + inline size_type nRows() const { return nrows; } + inline size_type nCols() const { return ncols; } + inline size_type nNonZerosPerRow() const { return nnzpr; } + inline size_type nNonZeros() const { return nnzpr * nrows; } + inline size_type nNonZerosInOutput() const { return output_nnz; } + inline value_type getHysteresis() const { return hysteresis; } + inline value_type getStimulusThreshold() const { return stimulus_threshold; } + inline value_type getHistogramThreshold() const { return histogram_threshold; } + inline value_type getNormalizationSum() const { return normalization_sum; } + inline value_type getNormalizationFreq() const { return normalization_freq; } + + //-------------------------------------------------------------------------------- + inline void reset() + { + n_prev_winners = 0; + } + + //-------------------------------------------------------------------------------- + /** + * For inspectors. + * This makes compute slower. + */ + inline void setStoreDenseOutput(bool x) + { + if (x) { + d_output.resize(nbabies); + for (size_type i = 0; i != nbabies; ++i) + d_output[i].resize(nrows); + } else { + d_output.resize(0); + } + } + + //-------------------------------------------------------------------------------- + /** + * For inspectors, only if setStoreDenseOutput(true) was called before! + */ + inline std::vector getDenseOutput(size_type babyIdx) const + { + NTA_ASSERT(babyIdx < nbabies); + NTA_ASSERT(!d_output.empty()); + + return d_output[babyIdx]; + } + + //-------------------------------------------------------------------------------- + /** + * For debugging. + */ + inline std::vector getPrevWinners() const + { + return + std::vector(prev_winners.begin(), prev_winners.begin() + n_prev_winners); + } + + //-------------------------------------------------------------------------------- + /** + * Mostly for debugging, returns vector of positions of last element on each row + * that has a counter > histogram_threshold. + */ + const std::vector& get_ub() const { return ub; } + + //-------------------------------------------------------------------------------- + /** + * Set our coincidences from a SM in csr format (in Python, create the string with + * toPyString()). Resets dimensions to be dimensions of the SM. Also resets ub[i] + * to nnzpr. Assumes that all the rows in the SM have exactly the same number of + * non-zeros (assert). n_bytes is added by SM toCSR, just after the format tag, + * but we don't need it here: we load it and ignore it. + * + * NOTE: the C++ implementation of FDR SP has a single sparse matrix to store *BOTH* + * coincidences' non-zero indices and coincidences' bit counts! Python maintains + * two separate data structures. + * + * NOTE: watch out! If you use this method, it does reset ub[i] to nnzpr, i.e. + * all the bits of all coincidences will be used for matching. + * + * NOTE: the matrix passed in needs to be already normalized. + */ + inline void set_cm(const std::string& cm_string) + { + { + NTA_ASSERT(!cm_string.empty()); + } + + std::stringstream cm_stream(cm_string); + + std::string tag; + cm_stream >> tag; + if (tag != "csr" && tag != "sm_csr_1.5") { + std::cout << "Unknown format for coincidence matrix: " + << tag << std::endl; + exit(-1); + } + + size_type n_bytes = 0, k = 0, nnz = 0; + + cm_stream >> n_bytes >> nrows >> ncols >> nnz; + + ind_nz.resize(nnz); + ub.resize(nrows); + + for (size_type i = 0; i != nrows; ++i) { + + size_type nnz_this_row = 0; + cm_stream >> nnz_this_row; + + if (i == 0) + nnzpr = nnz_this_row; + else + if (nnz_this_row != nnzpr) { + std::cout << "More non-zeros on row " << i + << " than expected (" << nnzpr << ")" + << std::endl; + exit(-1); + } + + for (size_type j = 0; j != nnzpr; ++j, ++k) { + cm_stream >> ind_nz[k].first >> ind_nz[k].second; + if (ind_nz[k].first >= ncols) { + std::cout << "Column index out of bound: " << ind_nz[k].first + << " for non-zero #" << k + << " on row " << i + << std::endl; + exit(-1); + } + } + + ub[i] = nnzpr; + } + + //normalize(); + + { + NTA_ASSERT(k == nnz); + NTA_ASSERT(ind_nz.size() == nnz); + NTA_ASSERT(ub.size() == nRows()); + } + } + + //-------------------------------------------------------------------------------- + /** + * Sets the coincidence matrix/histogram directly from a dense array. That makes + * the Python code much easier (can set directly from a numpy dense array). + */ + template + inline void set_cm_from_dense(It begin, It end) + { + { + NTA_ASSERT((size_type)(end - begin) == nrows * ncols); + NTA_ASSERT(ind_nz.size() == nrows * nnzpr); + } + + size_type k = 0; + + for (size_type i = 0; i != nrows; ++i) { + for (size_type j = 0; j != ncols; ++j) { + if (begin[i*ncols+j] != 0) + ind_nz[k++] = std::make_pair(j, begin[i*ncols+j]); + } + if (k != (i+1) * nnzpr) { + std::cout << "Wrong number of non-zeros on row " << i + << " - expected: " << nnzpr + << " got: " << k << std::endl; + exit(-1); + } + } + } + + //-------------------------------------------------------------------------------- + /** + * Returns coincidence matrix in csr format. That string can be used to initialize + * a SparseMatrix (with constructor in Python). Duplicating nnzpr at the head of + * each row so that the format is compatible with SM csr. To make this string + * compatible with SM fromCSR, we need to add the byte size of the string right + * after the format tag. + * + * NOTE: slow, because resorts the non-zeros on each row to be compatible with SM. + */ + inline std::string get_cm() const + { + std::stringstream cm_stream1, cm_stream2; + + cm_stream1 << "sm_csr_1.5 "; + cm_stream2 << nrows << ' ' + << ncols << ' ' + << ind_nz.size() << ' '; + + for (size_type i = 0; i != nrows; ++i) { + cm_stream2 << nnzpr << ' '; + std::vector buffer(nnzpr); + std::copy(row_begin(i), row_begin(i) + nnzpr, buffer.begin()); + std::sort(buffer.begin(), buffer.end(), less_1st()); + for (size_type j = 0; j != nnzpr; ++j) + cm_stream2 << buffer[j].first << ' ' << buffer[j].second << ' '; + } + + cm_stream1 << cm_stream2.str().size() << ' ' << cm_stream2.str(); + return cm_stream1.str(); + } + + //-------------------------------------------------------------------------------- + /** + * Returns coincidence matrix in csr format, but only the non-zeros which have + * a bit count greater than histogram_threshold. + */ + inline std::string get_truncated_cm() const + { + std::stringstream cm_stream1, cm_stream2; + + cm_stream1 << "sm_csr_1.5 "; + cm_stream2 << nrows << ' ' + << ncols << ' ' + << ind_nz.size() << ' '; + + for (size_type i = 0; i != nrows; ++i) { + cm_stream2 << ub[i] << ' '; + std::vector buffer(nnzpr); + std::copy(row_begin(i), row_begin(i) + ub[i], buffer.begin()); + std::sort(buffer.begin(), buffer.begin() + ub[i], + less_1st()); + for (size_type j = 0; j != ub[i]; ++j) + cm_stream2 << buffer[j].first << ' ' << buffer[j].second << ' '; + } + + cm_stream1 << cm_stream2.str().size() << ' ' << cm_stream2.str(); + return cm_stream1.str(); + } + + //-------------------------------------------------------------------------------- + /** + * Return a single row of the coincidence matrix, as a dense vector. + * First requested for inspectors. + */ + template + inline void get_cm_row_dense(size_type row, It begin, It end) const + { + { + NTA_ASSERT(row < nrows); + } + + std::fill(begin, end, 0); + + for (size_type i = 0; i != nnzpr; ++i) + *(begin + ind_nz[row*nnzpr + i].first) = ind_nz[row*nnzpr + i].second; + } + + //-------------------------------------------------------------------------------- + template + inline void get_cm_row_sparse(size_type row, It1 begin_ind, It2 begin_nz) const + { + { + NTA_ASSERT(row < nrows); + } + + std::vector buffer(nnzpr); + std::copy(row_begin(row), row_begin(row) + nnzpr, buffer.begin()); + std::sort(buffer.begin(), buffer.begin() + nnzpr, + less_1st()); + for (size_type j = 0; j != nnzpr; ++j) { + *begin_ind++ = buffer[j].first; + *begin_nz++ = buffer[j].second; + } + } + + //-------------------------------------------------------------------------------- + /** + * Returns the amount of overlap (the number of matching bits) between x and + * each coincidence. + * First requested for inspectors. + * + * Call in inference (matches only the _learnt_ bits of the coincidences). + */ + template + inline size_type overlaps(It1 x, It2 y2, It3 y3) + { + size_type n = 0; + + for (size_type i = 0; i != nrows; ++i) { + + if (y2[i] > 0) { + + value_type s = 0.0f; + size_type *p = &ind_nz[i * nnzpr].first, *p_end = p + 2 * ub[i]; + + for (; p != p_end; p += 2) + s += x[*p]; + + *y3++ = s; + ++n; + } + } + + return n; + } + + //-------------------------------------------------------------------------------- + /** + * The update() method maintains the counts of the on bits of each coincidence, if + * learning is turned on: the bits that match with the inputs more are reinforced + * and the others are gradually ignored. The update() method has 3 parts. + * + * This method takes in a vector of the indices of the active coincidences, and + * the input vector (needed to compute the overlap with each coincidence and + * increment the bit counters accordingly). + * + * 1. Increment coincidence bit counts: + * =================================== + * For the active coincidences only, we increment the counts of the bits that match + * between the coincidence and x. This will increase the likelihood that "useful" + * bits get promoted for each coincidence, while the bits that don't match enough + * will be made irrelevant. For the purpose of incrementing the counts, we need to + * consider _all_ the non-zeros of each active coincidence, not only the non-zeros + * up to ub[i], since we want the set of "important" bits to be dynamic: new + * "important" bits can enter the set at any point, depending on the statistics + * of the inputs. + * + * 3. Normalize, infrequently: + * ========================== + * Once in a while, we normalize, which has the effect of pushing some coincidence + * bits below the threshold, making them irrelevant for further inferences. This + * operations is done only infrequently because it takes too much time to be done + * on each input vector. It can be thought of as an "inhibition", the more + * relevant bits "inhibiting" those that don't match the inputs often enough. The + * whole row is normalized, including the bits that are 'less relevant' (after + * ub[i]). We normalize *ALL* rows, so that we also normalize rows that were + * updated in between the points at which we normalize (we normalize only every + * 10 steps, for example, but we we update rows on each iteration). + * + * 2. Segregate nz above/below threshold: + * ===================================== + * We update ub[i] for each active row i by sorting the whole row + * and then finding the new ub[i]. Non-zeros with a count above threshold are + * stored before ub[i], and the others after. Note that to segregate correctly, + * we need to take into account both the non-zeros that are currently *above* + * and *below* threshold: depending on the statistics of the input, those two + * sets can change from iteration to iteration. Which means we need to sort + * and threshold on each iteration, *AFTER* incrementing the counts and normalizing + * them. + * + * Parameters: + * ========== + * - active..active_end: a vector containing the indices of the active + * coincidences (size <= nrows) + * - x..x_end: the input vector (size == ncols) + * + * TODO: maintain ub[i] incrementally instead of sorting each time + * TODO: update only infrequently, and accumulate in the meantime + * TODO: see if it's faster to normalize only the active rows, on each iteration + * TODO: jump by 2 in 1. to avoid dereferencing the pair + */ + private: + template + inline void update(It1 active, It1 active_end, It2 x, It2 x_end) + { + { // Pre-conditions + NTA_ASSERT(active <= active_end); + NTA_ASSERT((size_type)(x_end - x) == ncols); + NTA_ASSERT(0 < normalization_freq); + NTA_ASSERT(0 < histogram_threshold); + NTA_ASSERT(ub.size() == nrows); + NTA_ASSERT(!ind_nz.empty() && ind_nz.size() == nrows * nnzpr); + for (size_type i = 0; i != ind_nz.size(); ++i) + NTA_ASSERT(ind_nz[i].first < ncols); + for (It1 it = active; it != active_end; ++it) + NTA_ASSERT(*it < nrows); + } // End pre-conditions + + // 1. Increment the counts up to nnzpr + for (It1 it = active; it != active_end; ++it) { + + size_type i = (size_type) *it; + IndNZ *p_beg = row_begin(i), *p_end = p_beg + nnzpr; + + for (IndNZ* p = p_beg; p != p_end; ++p) + p->second += x[p->first]; + } + + // 2. Normalize, infrequently + if (iter % normalization_freq == 0) { + + normalize(); + + // 3. Segregate nz above/below threshold (update ub[i]) + for (size_type i = 0; i != nrows; ++i) { + + size_type j = 0; + IndNZ *p_beg = row_begin(i), *p_end = p_beg + nnzpr; + + std::sort(p_beg, p_end, greater_2nd()); + + while (j < nnzpr && p_beg[j].second > histogram_threshold) + ++j; + + ub[i] = j; + } + } + + { // Post-conditions + //for (It1 it = active; it != active_end; ++it) + // NTA_ASSERT(ub[*it] <= nnzpr); + } // End post-conditions + } + + //-------------------------------------------------------------------------------- + /** + * The infer() method takes input vectors and produces output vectors that best + * "represent" the input w.r.t. to the matrix of coincidences. The input, output + * and coincidences are all sparse binary (0/1) vectors. The non-zeros of the output + * correspond to the coincidences that best match the input vector. The output + * always has constant sparsity (constant number of non-zeros = output_nnz), + * according to FDR principles. The infer method has 2 parts, and optionally + * calls update() to update the coincidences (if learning is on). + * + * This method takes in the input vector x and produces the result vector y which + * the output of the SP itself. The input is a binary 0/1 vector of size ncols + * (the size of the coincidences), and the output is another binary 0/1 vector, + * of size nrows (the number of coincidences). + * + * 1. Compute matches: + * ================== + * This step computes the number of overlapping bits between the input and each + * coincidence. This is achieved as follows: + * Multiply current sparse matrix (in ind_nz) by x on the right, place result into + * y. When doing that multiplication, for row i, we multiply up to ub[i] non-zeros + * only: if we are not doing learning, ub[i] == nnzpr (set in constructor) ; if we are + * learning, ub[i] gets adjusted in update() to the number of non-zeros whose values + * are > threshold. The order of the non-zeros doesn't matter here, except maybe to + * optimize cache usage (try sorting them in increasing order before ub[i]). While + * performing the right vec prod, we also count the number of matches that are + * greater than stimulus_threshold (n_gt). + * + * 2. Impose constant sparsity on outputs: + * ====================================== + * This step selects the top_n coincidences that best match x (highest number of + * overlapping bits), sets the corresponding bits of y to 1, and the others to + * 0 (inhibition). Before we set the bits of y to 0/1, we trigger learning with + * y's top_n first elements containing the indices of the non-zeros we will set + * in y, if doLearn is true. Finally, in_place_sparse_to_dense_01 expands y in + * place, from a vector of top_n indices to a binary 0/1 vector having 1's at + * the positions of the top_n indices only, and 0's elsewhere. + * + * Parameters: + * ========== + * - babyIdx: index of the baby that should compute on this call + * - x..x_end: input vector (input to the SP) + * - y..y_end: output vector (output of the SP) + * - doLearn: whether to learn or not + * - doInfer: whether to do inference or not + * + * IMPLEMENTATION NOTES: + * 1. If less than stimulus_threshold bits on in x, no coincidence + * will match properly, so we can return the null vector right + * away. + * + * 2. We use n_gt with two different meanings in this function: first, + * it counts the number of on bits in x. Then we reuse it to mean the + * number of coincidences that match x above stimulus_threshold. + * + * 3. To compute the right vec prod (that computes the overlap between the + * coincidences and the input vector) in 1. (hotspot), the loop "jumps over" + * by increments of two, because the coincidences are stored as vector of + * pair(index,counter value), and we need only the indices here. This is much + * faster than iterating on each pair, and dereferencing with pair.first. + * + * TODO: measure impact of sorted non-zeros before ub[i] on cache + * TODO: return only the indices of the non-zeros in the output, once + * integrated with the FDR TP + * TODO: write faster asm count_non_zeros (the current one uses count_gt) + * TODO: avoid having to resort for in_place_sparse_to_dense_01 (requires + * writing another in_place_sparse_to_dense_01) + */ + public: + template + inline void compute(size_type babyIdx, + It1 x, It1 x_end, It2 y, It2 y_end, + bool doLearn =false, bool doInfer =true) + { + { // Pre-conditions + NTA_ASSERT(babyIdx < nbabies); + NTA_ASSERT((size_type)(x_end - x) == ncols); + NTA_ASSERT((size_type)(y_end - y) == nrows); + NTA_ASSERT(!ind_nz.empty() && ind_nz.size() == nrows * nnzpr); + NTA_ASSERT(ub.size() == nrows); + for (size_type i = 0; i != ub.size(); ++i) + NTA_ASSERT(ub[i] <= nnzpr); + for (size_type i = 0; i != ind_nz.size(); ++i) + NTA_ASSERT(ind_nz[i].first < ncols); + } // End pre-conditions + + // 0. Compute number of on bits in input vector x + size_type n_gt = count_non_zeros(x, x_end); + + if (n_gt <= stimulus_threshold) { + std::fill(y, y_end, 0); + return; + } + + // 1. Compute matches + n_gt = 0; + + for (size_type i = 0; i != nrows; ++i) { + + // *** HOTSPOT *** in r26326 + value_type s = 0.0f; + size_type *p = &ind_nz[i * nnzpr].first, *p_end = p + 2 * ub[i]; + + for (; p != p_end; p += 2) + s += x[*p]; + + y[i] = s; + } + + if (hysteresis > 1.0f) { + size_type *i = &prev_winners[0], *i_end = i + n_prev_winners; + for (; i != i_end; ++i) + y[*i] *= hysteresis; + } + + for (size_type i = 0; i != nrows; ++i) + if (y[i] > stimulus_threshold) + ++n_gt; + + // Only for inspectors, slow, off by default + if (!d_output.empty()) + std::copy(y, y_end, d_output[babyIdx].begin()); + + // 2. Impose constant output sparsity + size_type top_n = std::min(output_nnz, n_gt); + + if (top_n == 0) { + std::fill(y, y_end, 0); + return; + } + + partial_argsort(top_n, y, y_end, y, y_end); + + if (doLearn) + update(y, y + top_n, x, x_end); + + if (hysteresis > 1.0f) { + n_prev_winners = top_n; + std::copy(y, y + top_n, prev_winners.begin()); + } + + // TODO: disconnect this if doInfer is false + // in_place_sparse_to_dense_01 requires sorted indices! + std::sort(y, y + top_n); + in_place_sparse_to_dense_01(top_n, y, y_end); + + ++iter; + } + + //-------------------------------------------------------------------------------- + // PERSISTENCE + //-------------------------------------------------------------------------------- + /** + * This methods to pickle/unpickle a FDRSpatial. + */ + inline size_type persistent_size() const + { + std::stringstream buff; + save(buff); + return buff.str().size(); + } + + //-------------------------------------------------------------------------------- + inline void save(std::ostream& out_stream) const + { + { + NTA_ASSERT(out_stream.good()); + NTA_ASSERT(ind_nz.size() == nrows * nnzpr); + NTA_ASSERT(ub.size() == nRows()); + for (size_type i = 0; i != ind_nz.size(); ++i) + NTA_ASSERT(ind_nz[i].first < ncols); + } + + out_stream << version() << ' ' << nbabies << ' ' + << nrows << ' ' << ncols << ' ' << nnzpr << ' ' + << iter << ' ' + << output_nnz << ' ' + << hysteresis << ' ' + << stimulus_threshold << ' ' + << histogram_threshold << ' ' + << normalization_sum << ' ' + << normalization_freq << ' ' + << ub << ' ' + << ind_nz << ' ' + << n_prev_winners << ' ' + << prev_winners << ' '; + } + + //-------------------------------------------------------------------------------- + inline void load(std::istream& in_stream) + { + { + NTA_ASSERT(in_stream.good()); + } + + std::string ver; + in_stream >> ver; + assert(ver == version()); + + in_stream >> nbabies + >> nrows >> ncols >> nnzpr >> iter + >> output_nnz + >> hysteresis + >> stimulus_threshold + >> histogram_threshold + >> normalization_sum + >> normalization_freq + >> ub + >> ind_nz + >> n_prev_winners + >> prev_winners; + + d_output.resize(0); + + { + NTA_ASSERT(ind_nz.size() == nrows * nnzpr); + NTA_ASSERT(1.0 <= hysteresis); + NTA_ASSERT(0 < histogram_threshold); + NTA_ASSERT(0 < normalization_sum); + NTA_ASSERT(0 < normalization_freq); + NTA_ASSERT(ub.size() == nRows()); + for (size_type i = 0; i != ub.size(); ++i) + NTA_ASSERT(ub[i] <= nnzpr); + for (size_type i = 0; i != ind_nz.size(); ++i) + NTA_ASSERT(ind_nz[i].first < ncols); + } + } + + private: + + //-------------------------------------------------------------------------------- + /** + * Returns a pointer to the first (index,value) pair of row i. + */ + inline IndNZ* row_begin(size_type i) + { + NTA_ASSERT(i < nRows()); + return &ind_nz[0] + i * nnzpr; + } + + //-------------------------------------------------------------------------------- + /** + * Returns a pointer to the first (index,value) pair of row i. + */ + inline const IndNZ* row_begin(size_type i) const + { + NTA_ASSERT(i < nRows()); + return &ind_nz[0] + i * nnzpr; + } + + //-------------------------------------------------------------------------------- + /** + * Normalizes each row of the coincidence matrix separately, so that the sum + * of each column is equal to normalization_sum (set in constructor). + */ + inline void normalize() + { + NTA_ASSERT(0 < normalization_sum); + + for (size_type i = 0; i != nrows; ++i) { + IndNZ* p_beg = row_begin(i), *p_end = p_beg + nnzpr; + value_type s = 0.0f; + for (IndNZ* p = p_beg; p != p_end; ++p) + s += p->second; + if (s == 0.0f) + return; + value_type k = normalization_sum / s; + NTA_ASSERT(k != 0.0f); + for (IndNZ* p = p_beg; p != p_end; ++p) + p->second *= k; + } + } + + //-------------------------------------------------------------------------------- + size_type nbabies; + size_type nrows, ncols, nnzpr; // nnzpr = number of non-zeros per row + size_type iter; // current iteration number + size_type output_nnz; // number of nz desired in output vector + value_type hysteresis; // hysteresis factor + value_type stimulus_threshold; // see infer() + value_type histogram_threshold; // see update() + value_type normalization_sum; // see update() + size_type normalization_freq; // see update() + + std::vector ub; // ub[row] = 1+index of last nz > histogram_threshold + std::vector ind_nz; // vectors of pairs + + size_type n_prev_winners; // for hysteresis, n of prev winners + std::vector prev_winners; // for hysteresis + + // for inspectors only, makes compute slow + std::vector > d_output; + }; + + //-------------------------------------------------------------------------------- + } // end namespace algorithms +} // end namespace nupic + +#endif // NTA_FDR_SPATIAL_HPP From 94a9c53280d61966ae6fe675bb2c25004140dd71 Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Thu, 5 Mar 2015 19:24:12 +0100 Subject: [PATCH 024/100] fix TP.initialize() problem + cleanup --- src/examples/nupic/algorithms/HelloSP_TP.cpp | 65 ++++++++++---------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/src/examples/nupic/algorithms/HelloSP_TP.cpp b/src/examples/nupic/algorithms/HelloSP_TP.cpp index 00680b0b67..39c49b7646 100644 --- a/src/examples/nupic/algorithms/HelloSP_TP.cpp +++ b/src/examples/nupic/algorithms/HelloSP_TP.cpp @@ -25,6 +25,7 @@ #include // std::generate #include // std::time #include // std::rand, std::srand +#include // pow #include "nupic/algorithms/SpatialPooler.hpp" #include "nupic/algorithms/Cells4.hpp" @@ -35,54 +36,52 @@ using namespace nupic::algorithms::spatial_pooler; using namespace nupic::algorithms::Cells4; // function generator: -int RandomNumber01 () { return (rand()%2); } +int RandomNumber01 () { return (rand()%2); } // returns random (binary) numbers from {0,1} int main(int argc, const char * argv[]) { -const int DIM = 2048; +const int DIM = 2048; // number of columns in SP, TP const int DIM_INPUT = 10000; +const int TP_CELLS_PER_COL = 10; // cells per column in TP +const int EPOCHS = pow(10, 4); // number of iterations (calls to SP/TP compute() ) - vector inputDim; - inputDim.push_back(DIM_INPUT); - inputDim.push_back(1); + vector inputDim = {DIM_INPUT}; + vector colDim = {DIM}; - vector colDim; - colDim.push_back(DIM); - colDim.push_back(1); + // generate random input + vector input(DIM_INPUT); + vector outSP(DIM); // active array, output of SP/TP + const int _CELLS = DIM * TP_CELLS_PER_COL; + vector outTP(_CELLS); + Real rIn[DIM] = {}; // input for TP (must be Reals) + Real rOut[_CELLS] = {}; - // generate random input - vector input(DIM_INPUT); - generate(input.begin(), input.end(), RandomNumber01); - vector outSP(DIM); // active array, output of SP/TP - vector outTP(DIM); - -// cout << "input=" << input << endl; - - SpatialPooler sp(inputDim, colDim); - Cells4 tp; - tp.initialize(DIM); + // initialize SP, TP + SpatialPooler sp(inputDim, colDim); + Cells4 tp(DIM, TP_CELLS_PER_COL, 12, 8, 15, 5, .5, .8, 1.0, .1, .1, 0.0, false, 42, true, false); - //run + //run + for (int e=0; e< EPOCHS; e++) { + generate(input.begin(), input.end(), RandomNumber01); fill(outSP.begin(), outSP.end(), 0); sp.compute(input.data(), true, outSP.data()); - cout << "SP=" << outSP << endl; - - fill(outTP.begin(), outTP.end(), 0); - Real rIn[DIM] = {}; // default size from constructor - const UInt CELLS = DIM*10; - Real rOut[CELLS] = {}; - - cout << "TP:" << endl; for (int i=0; i< DIM; i++) { rIn[i] = (Real)(outSP[i]); - cout << rIn[i]; - cout << rOut[i]; } - cout << "OK" << endl; tp.compute(rIn, rOut, true, true); - cout << "TP=" << rOut << endl; - return 0; + for (int i=0; i< _CELLS; i++) { + outTP[i] = (UInt)rOut[i]; + } + + // print + if (e == EPOCHS-1) { + cout << "Epoch = " << e << endl; + cout << "SP=" << outSP << endl; + cout << "TP=" << outTP << endl; + } + } + return 0; } From 9b33b5750d51f0c1f0855d4beb0a5546c9d72305 Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Thu, 5 Mar 2015 19:29:41 +0100 Subject: [PATCH 025/100] add readme for profiling SP/TP HelloWorld file --- src/examples/nupic/algorithms/Readme.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/examples/nupic/algorithms/Readme.md diff --git a/src/examples/nupic/algorithms/Readme.md b/src/examples/nupic/algorithms/Readme.md new file mode 100644 index 0000000000..601278830b --- /dev/null +++ b/src/examples/nupic/algorithms/Readme.md @@ -0,0 +1,17 @@ +## C++ NuPIC HelloWorld example + +This file serves two purposes: + +#### Demo C++ aplication + +Using only C++ `nupic.core` implementations, currently the chain uses +` SpatialPooler > TemporalPooler` + +More classes should be added as they are ported (Encoders, Classifier, Anomaly, ...) + +#### Profiling code + +For ongoing optimization goals, we need a simple but complete code to run benchmarks and profile. +You can easily change the constants (`EPOCHS, DIM,...`) and try this code on your branch. + + From f272adffa181d6d0c08e7280600ba915b9874c47 Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Thu, 5 Mar 2015 20:48:11 +0100 Subject: [PATCH 026/100] chain default constructor from parametrized SpatialPooler() constructor --- src/nupic/algorithms/SpatialPooler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nupic/algorithms/SpatialPooler.cpp b/src/nupic/algorithms/SpatialPooler.cpp index 3fc61e52e4..a24ad381ff 100644 --- a/src/nupic/algorithms/SpatialPooler.cpp +++ b/src/nupic/algorithms/SpatialPooler.cpp @@ -135,7 +135,7 @@ SpatialPooler::SpatialPooler(vector inputDimensions, Real maxBoost, Int seed, UInt spVerbosity, - bool wrapAround) + bool wrapAround) : SpatialPooler::SpatialPooler() { initialize( inputDimensions, columnDimensions, From b85f3ee8b1d172ceffa60d23822555c5bb3529c8 Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Thu, 5 Mar 2015 20:50:12 +0100 Subject: [PATCH 027/100] move examples location --- src/CMakeLists.txt | 2 +- src/examples/{nupic => }/algorithms/HelloSP_TP.cpp | 0 src/examples/{nupic => }/algorithms/Readme.md | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename src/examples/{nupic => }/algorithms/HelloSP_TP.cpp (100%) rename src/examples/{nupic => }/algorithms/Readme.md (100%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 915ce9dc23..084ee6d7d3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -465,7 +465,7 @@ add_dependencies(${EXECUTABLE_PROTOTEST} ${COMMON_LIBS}) # Setup HelloSP_TP example # set(EXECUTABLE_HELLOSPTP hello_sp_tp) -add_executable(${EXECUTABLE_HELLOSPTP} examples/nupic/algorithms/HelloSP_TP.cpp) +add_executable(${EXECUTABLE_HELLOSPTP} examples/algorithms/HelloSP_TP.cpp) target_link_libraries(${EXECUTABLE_HELLOSPTP} ${COMMON_LIBS}) set_target_properties(${EXECUTABLE_HELLOSPTP} PROPERTIES COMPILE_FLAGS ${COMMON_COMPILE_FLAGS}) set_target_properties(${EXECUTABLE_HELLOSPTP} PROPERTIES LINK_FLAGS "${COMMON_LINK_FLAGS}") diff --git a/src/examples/nupic/algorithms/HelloSP_TP.cpp b/src/examples/algorithms/HelloSP_TP.cpp similarity index 100% rename from src/examples/nupic/algorithms/HelloSP_TP.cpp rename to src/examples/algorithms/HelloSP_TP.cpp diff --git a/src/examples/nupic/algorithms/Readme.md b/src/examples/algorithms/Readme.md similarity index 100% rename from src/examples/nupic/algorithms/Readme.md rename to src/examples/algorithms/Readme.md From 4525280c4166162a1253c71d7f9841f75eb8c9cb Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Thu, 5 Mar 2015 20:52:15 +0100 Subject: [PATCH 028/100] review --- src/examples/algorithms/HelloSP_TP.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/examples/algorithms/HelloSP_TP.cpp b/src/examples/algorithms/HelloSP_TP.cpp index 39c49b7646..57e909e9d9 100644 --- a/src/examples/algorithms/HelloSP_TP.cpp +++ b/src/examples/algorithms/HelloSP_TP.cpp @@ -1,6 +1,6 @@ /* --------------------------------------------------------------------- * Numenta Platform for Intelligent Computing (NuPIC) - * Copyright (C) 2013-2014, Numenta, Inc. Unless you have an agreement + * Copyright (C) 2013-2015, Numenta, Inc. Unless you have an agreement * with Numenta, Inc., for a separate license for this software code, the * following terms and conditions apply: * From 35e6d225b4dd8b2fc9170998d616d8ea85e0544f Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Fri, 6 Mar 2015 12:54:07 +0100 Subject: [PATCH 029/100] review 2 - import only SP,Cells4 class --- src/examples/algorithms/HelloSP_TP.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/examples/algorithms/HelloSP_TP.cpp b/src/examples/algorithms/HelloSP_TP.cpp index 57e909e9d9..ab7061bfc0 100644 --- a/src/examples/algorithms/HelloSP_TP.cpp +++ b/src/examples/algorithms/HelloSP_TP.cpp @@ -32,8 +32,8 @@ using namespace std; using namespace nupic; -using namespace nupic::algorithms::spatial_pooler; -using namespace nupic::algorithms::Cells4; +using nupic::algorithms::spatial_pooler::SpatialPooler; +using nupic::algorithms::Cells4::Cells4; // function generator: int RandomNumber01 () { return (rand()%2); } // returns random (binary) numbers from {0,1} From 87d417bece1277c7eb72669a8467654786c54eda Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Fri, 6 Mar 2015 13:44:49 +0100 Subject: [PATCH 030/100] fix use UInt for DIM, ... fixes Win builds thanks @rcrowder --- src/examples/algorithms/HelloSP_TP.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/examples/algorithms/HelloSP_TP.cpp b/src/examples/algorithms/HelloSP_TP.cpp index ab7061bfc0..e3d6705ef9 100644 --- a/src/examples/algorithms/HelloSP_TP.cpp +++ b/src/examples/algorithms/HelloSP_TP.cpp @@ -40,10 +40,10 @@ int RandomNumber01 () { return (rand()%2); } // returns random (binary) numbers int main(int argc, const char * argv[]) { -const int DIM = 2048; // number of columns in SP, TP -const int DIM_INPUT = 10000; -const int TP_CELLS_PER_COL = 10; // cells per column in TP -const int EPOCHS = pow(10, 4); // number of iterations (calls to SP/TP compute() ) +const UInt DIM = 2048; // number of columns in SP, TP +const UInt DIM_INPUT = 10000; +const UInt TP_CELLS_PER_COL = 10; // cells per column in TP +const UInt EPOCHS = pow(10, 4); // number of iterations (calls to SP/TP compute() ) vector inputDim = {DIM_INPUT}; vector colDim = {DIM}; From 176887e8a50da3abb27887a7f205bce59202b48d Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Fri, 6 Mar 2015 13:57:55 +0100 Subject: [PATCH 031/100] small fix --- src/examples/algorithms/HelloSP_TP.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/examples/algorithms/HelloSP_TP.cpp b/src/examples/algorithms/HelloSP_TP.cpp index e3d6705ef9..a0c5ca87f6 100644 --- a/src/examples/algorithms/HelloSP_TP.cpp +++ b/src/examples/algorithms/HelloSP_TP.cpp @@ -61,18 +61,18 @@ const UInt EPOCHS = pow(10, 4); // number of iterations (calls to SP/TP compute( Cells4 tp(DIM, TP_CELLS_PER_COL, 12, 8, 15, 5, .5, .8, 1.0, .1, .1, 0.0, false, 42, true, false); //run - for (int e=0; e< EPOCHS; e++) { + for (UInt e=0; e< EPOCHS; e++) { generate(input.begin(), input.end(), RandomNumber01); fill(outSP.begin(), outSP.end(), 0); sp.compute(input.data(), true, outSP.data()); - for (int i=0; i< DIM; i++) { + for (UInt i=0; i< DIM; i++) { rIn[i] = (Real)(outSP[i]); } tp.compute(rIn, rOut, true, true); - for (int i=0; i< _CELLS; i++) { + for (UInt i=0; i< _CELLS; i++) { outTP[i] = (UInt)rOut[i]; } From 0b62e2154adef90e68cf41913507f05e1409bf24 Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Fri, 6 Mar 2015 19:16:36 +0100 Subject: [PATCH 032/100] add nupic::Timer functionality from @rcrowder --- src/examples/algorithms/HelloSP_TP.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/examples/algorithms/HelloSP_TP.cpp b/src/examples/algorithms/HelloSP_TP.cpp index a0c5ca87f6..a9839d8d6c 100644 --- a/src/examples/algorithms/HelloSP_TP.cpp +++ b/src/examples/algorithms/HelloSP_TP.cpp @@ -29,6 +29,7 @@ #include "nupic/algorithms/SpatialPooler.hpp" #include "nupic/algorithms/Cells4.hpp" +#include "nupic/os/Timer.hpp" using namespace std; using namespace nupic; @@ -60,6 +61,9 @@ const UInt EPOCHS = pow(10, 4); // number of iterations (calls to SP/TP compute( SpatialPooler sp(inputDim, colDim); Cells4 tp(DIM, TP_CELLS_PER_COL, 12, 8, 15, 5, .5, .8, 1.0, .1, .1, 0.0, false, 42, true, false); + // Start a stopwatch timer + Timer stopwatch(true); + //run for (UInt e=0; e< EPOCHS; e++) { generate(input.begin(), input.end(), RandomNumber01); @@ -82,6 +86,9 @@ const UInt EPOCHS = pow(10, 4); // number of iterations (calls to SP/TP compute( cout << "SP=" << outSP << endl; cout << "TP=" << outTP << endl; } + + stopwatch.stop(); + cout << "Total elapsed time = " << stopwatch.getElapsed() << " seconds" << endl; } return 0; } From fa18379fc0550f479f5005d1f048353cdfe5f13d Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Fri, 6 Mar 2015 19:30:47 +0100 Subject: [PATCH 033/100] whoops, wrong bracket :) --- src/examples/algorithms/HelloSP_TP.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/examples/algorithms/HelloSP_TP.cpp b/src/examples/algorithms/HelloSP_TP.cpp index a9839d8d6c..112f5e89b8 100644 --- a/src/examples/algorithms/HelloSP_TP.cpp +++ b/src/examples/algorithms/HelloSP_TP.cpp @@ -86,9 +86,10 @@ const UInt EPOCHS = pow(10, 4); // number of iterations (calls to SP/TP compute( cout << "SP=" << outSP << endl; cout << "TP=" << outTP << endl; } + } stopwatch.stop(); cout << "Total elapsed time = " << stopwatch.getElapsed() << " seconds" << endl; - } + return 0; } From 6f7e174cb8805fcdb3b8ada53b15a9576b271066 Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Sat, 7 Mar 2015 00:26:27 +0100 Subject: [PATCH 034/100] review 3 --- src/examples/algorithms/Readme.md | 6 ++--- src/nupic/algorithms/SpatialPooler.hpp | 34 +++++++++++++------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/examples/algorithms/Readme.md b/src/examples/algorithms/Readme.md index 601278830b..7efdaf56a8 100644 --- a/src/examples/algorithms/Readme.md +++ b/src/examples/algorithms/Readme.md @@ -1,15 +1,15 @@ -## C++ NuPIC HelloWorld example +# C++ NuPIC HelloWorld example This file serves two purposes: -#### Demo C++ aplication +## Demo C++ aplication Using only C++ `nupic.core` implementations, currently the chain uses ` SpatialPooler > TemporalPooler` More classes should be added as they are ported (Encoders, Classifier, Anomaly, ...) -#### Profiling code +## Profiling code For ongoing optimization goals, we need a simple but complete code to run benchmarks and profile. You can easily change the constants (`EPOCHS, DIM,...`) and try this code on your branch. diff --git a/src/nupic/algorithms/SpatialPooler.hpp b/src/nupic/algorithms/SpatialPooler.hpp index 2dd8907632..c79272ee93 100644 --- a/src/nupic/algorithms/SpatialPooler.hpp +++ b/src/nupic/algorithms/SpatialPooler.hpp @@ -70,23 +70,23 @@ namespace nupic { public: SpatialPooler(); SpatialPooler(vector inputDimensions, - vector columnDimensions, - UInt potentialRadius=16, - Real potentialPct=0.5, - bool globalInhibition=true, - Real localAreaDensity=-1.0, - UInt numActiveColumnsPerInhArea=10, - UInt stimulusThreshold=0, - Real synPermInactiveDec=0.01, - Real synPermActiveInc=0.1, - Real synPermConnected=0.1, - Real minPctOverlapDutyCycles=0.001, - Real minPctActiveDutyCycles=0.001, - UInt dutyCyclePeriod=1000, - Real maxBoost=10.0, - Int seed=1, - UInt spVerbosity=0, - bool wrapAround=true); + vector columnDimensions, + UInt potentialRadius=16, + Real potentialPct=0.5, + bool globalInhibition=true, + Real localAreaDensity=-1.0, + UInt numActiveColumnsPerInhArea=10, + UInt stimulusThreshold=0, + Real synPermInactiveDec=0.01, + Real synPermActiveInc=0.1, + Real synPermConnected=0.1, + Real minPctOverlapDutyCycles=0.001, + Real minPctActiveDutyCycles=0.001, + UInt dutyCyclePeriod=1000, + Real maxBoost=10.0, + Int seed=1, + UInt spVerbosity=0, + bool wrapAround=true); virtual ~SpatialPooler() {} From dc83dca766f6dd7afa861ef2e467b7c1cb46462f Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Sat, 7 Mar 2015 00:26:52 +0100 Subject: [PATCH 035/100] use nupic::Random --- src/examples/algorithms/HelloSP_TP.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/examples/algorithms/HelloSP_TP.cpp b/src/examples/algorithms/HelloSP_TP.cpp index 112f5e89b8..416d0cbacb 100644 --- a/src/examples/algorithms/HelloSP_TP.cpp +++ b/src/examples/algorithms/HelloSP_TP.cpp @@ -24,20 +24,19 @@ #include #include // std::generate #include // std::time -#include // std::rand, std::srand #include // pow #include "nupic/algorithms/SpatialPooler.hpp" #include "nupic/algorithms/Cells4.hpp" #include "nupic/os/Timer.hpp" +#include "nupic/utils/Random.hpp" + using namespace std; using namespace nupic; using nupic::algorithms::spatial_pooler::SpatialPooler; using nupic::algorithms::Cells4::Cells4; -// function generator: -int RandomNumber01 () { return (rand()%2); } // returns random (binary) numbers from {0,1} int main(int argc, const char * argv[]) { @@ -49,13 +48,13 @@ const UInt EPOCHS = pow(10, 4); // number of iterations (calls to SP/TP compute( vector inputDim = {DIM_INPUT}; vector colDim = {DIM}; - // generate random input vector input(DIM_INPUT); vector outSP(DIM); // active array, output of SP/TP const int _CELLS = DIM * TP_CELLS_PER_COL; vector outTP(_CELLS); Real rIn[DIM] = {}; // input for TP (must be Reals) Real rOut[_CELLS] = {}; + Random rand01; // initialize SP, TP SpatialPooler sp(inputDim, colDim); @@ -66,14 +65,17 @@ const UInt EPOCHS = pow(10, 4); // number of iterations (calls to SP/TP compute( //run for (UInt e=0; e< EPOCHS; e++) { - generate(input.begin(), input.end(), RandomNumber01); + // generate random input + generate(input.begin(), input.end(), rand01()); // populate with rand 0/1 + cout << "rnd " << rand01() << endl; fill(outSP.begin(), outSP.end(), 0); + // Spatial pooler compute sp.compute(input.data(), true, outSP.data()); for (UInt i=0; i< DIM; i++) { rIn[i] = (Real)(outSP[i]); } - + // Temporal pooler compute tp.compute(rIn, rOut, true, true); for (UInt i=0; i< _CELLS; i++) { From 9634d6a1248b01a3fb1b8aa3abb8c2b287e83680 Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Sat, 7 Mar 2015 00:27:04 +0100 Subject: [PATCH 036/100] Revert "use nupic::Random" This reverts commit dc83dca766f6dd7afa861ef2e467b7c1cb46462f. --- src/examples/algorithms/HelloSP_TP.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/examples/algorithms/HelloSP_TP.cpp b/src/examples/algorithms/HelloSP_TP.cpp index 416d0cbacb..112f5e89b8 100644 --- a/src/examples/algorithms/HelloSP_TP.cpp +++ b/src/examples/algorithms/HelloSP_TP.cpp @@ -24,19 +24,20 @@ #include #include // std::generate #include // std::time +#include // std::rand, std::srand #include // pow #include "nupic/algorithms/SpatialPooler.hpp" #include "nupic/algorithms/Cells4.hpp" #include "nupic/os/Timer.hpp" -#include "nupic/utils/Random.hpp" - using namespace std; using namespace nupic; using nupic::algorithms::spatial_pooler::SpatialPooler; using nupic::algorithms::Cells4::Cells4; +// function generator: +int RandomNumber01 () { return (rand()%2); } // returns random (binary) numbers from {0,1} int main(int argc, const char * argv[]) { @@ -48,13 +49,13 @@ const UInt EPOCHS = pow(10, 4); // number of iterations (calls to SP/TP compute( vector inputDim = {DIM_INPUT}; vector colDim = {DIM}; + // generate random input vector input(DIM_INPUT); vector outSP(DIM); // active array, output of SP/TP const int _CELLS = DIM * TP_CELLS_PER_COL; vector outTP(_CELLS); Real rIn[DIM] = {}; // input for TP (must be Reals) Real rOut[_CELLS] = {}; - Random rand01; // initialize SP, TP SpatialPooler sp(inputDim, colDim); @@ -65,17 +66,14 @@ const UInt EPOCHS = pow(10, 4); // number of iterations (calls to SP/TP compute( //run for (UInt e=0; e< EPOCHS; e++) { - // generate random input - generate(input.begin(), input.end(), rand01()); // populate with rand 0/1 - cout << "rnd " << rand01() << endl; + generate(input.begin(), input.end(), RandomNumber01); fill(outSP.begin(), outSP.end(), 0); - // Spatial pooler compute sp.compute(input.data(), true, outSP.data()); for (UInt i=0; i< DIM; i++) { rIn[i] = (Real)(outSP[i]); } - // Temporal pooler compute + tp.compute(rIn, rOut, true, true); for (UInt i=0; i< _CELLS; i++) { From 5a1e85e98fa7bf6579208600ec00c440d0014a76 Mon Sep 17 00:00:00 2001 From: Richard Crowder Date: Sat, 7 Mar 2015 13:50:24 +0000 Subject: [PATCH 037/100] Test of AppVeyor.yml rewrite --- appveyor.yml | 107 +++++++++++++++++++++++++++------------------ src/CMakeLists.txt | 2 +- 2 files changed, 66 insertions(+), 43 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 4105b6b495..ed40aba35d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,17 +3,7 @@ #---------------------------------# # version format -version: 1.0.{build} - -branches: - # whitelist - only: - - master - - 311-appveyor-s3-support - - # blacklist - except: - - gh-pages +version: 0.3.0.%APPVEYOR_REPO_COMMIT% #---------------------------------# # environment configuration # @@ -31,9 +21,10 @@ clone_folder: c:\projects\nupic-core environment: matrix: # Must add either GCC or CLang here - # ie. COMPILER_FAMILY: GNU + # i.e. - COMPILER_FAMILY: GNU - COMPILER_FAMILY: MSVC - DEPLOY_BUILD: 1 + DEPLOY_TO_S3: 1 + DEPLOY_TO_NUGET: 0 skip_commits: # Add [av skip] to commit messages to skip AppVeyor building @@ -47,65 +38,97 @@ skip_commits: # enable patching of AssemblyInfo.* files assembly_info: patch: true - file: AssemblyInfo.* - assembly_version: "1.0.{build}" + file: '**\AssemblyInfo.*' + assembly_version: "{version}" assembly_file_version: "{version}" assembly_informational_version: "{version}" +nuget: + account_feed: true + project_feed: true + disable_publish_on_pr: true # disable publishing of .nupkg artifacts to + # account/project feeds for pull request builds + configuration: Release install: - - mkdir C:\projects\nupic-core\build\ - - mkdir C:\projects\nupic-core\build\release - - mkdir C:\projects\nupic-core\build\scripts - - cd C:\projects\nupic-core\build\scripts + - set REPO_DIR="c:\projects\nupic-core" + - mkdir %REPO_DIR%\build\ + - mkdir %REPO_DIR%\build\release + - mkdir %REPO_DIR%\build\scripts + - cd %REPO_DIR%\build\scripts + # Need at least version 3.1.0 for the VS 2015 generator - ps: Start-FileDownload 'http://www.cmake.org/files/v3.1/cmake-3.1.0-win32-x86.zip' - ps: Write-Host '7z x cmake-3.1.0-win32-x86.zip' - ps: Start-Process -FilePath "7z" -ArgumentList "x -y cmake-3.1.0-win32-x86.zip" -Wait -Passthru - - set PATH="C:\projects\nupic-core\build\scripts\cmake-3.1.0-win32-x86\bin";%PATH% + - set PATH="%REPO_DIR%\build\scripts\cmake-3.1.0-win32-x86\bin";%PATH% - set PATH="C:\Program Files (x86)\MSBuild\14.0\Bin";%PATH% - echo %PATH% - -before_build: - - cd C:\projects\nupic-core\build\scripts - - cmake C:\projects\nupic-core\src -G "Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX=..\Release -DLIB_STATIC_APR1_LOC=..\..\external\windows64\lib\apr-1.lib -DLIB_STATIC_APRUTIL1_LOC=..\..\external\windows64\lib\aprutil-1.lib -DLIB_STATIC_YAML_CPP_LOC=..\..\external\windows64\lib\yaml-cpp.lib -DLIB_STATIC_YAML_LOC=..\..\external\windows64\lib\yaml.lib -DLIB_STATIC_Z_LOC=..\..\external\windows64\lib\z.lib -DLIB_STATIC_CAPNP_LOC=..\..\external\windows64\lib\capnp.lib -DLIB_STATIC_KJ_LOC=..\..\external\windows64\lib\kj.lib + - cd %REPO_DIR%\build\scripts + - set EXT_LIBS="%REPO_DIR%\external\windows64\lib" + - cmake %REPO_DIR%\src \ + -G "Visual Studio 14 2015 Win64" -Wno-dev \ + -DCMAKE_INSTALL_PREFIX=..\Release -DCMAKE_BUILD_TYPE=Release \ + -DLIB_STATIC_APR1_LOC=%EXT_LIBS%\apr-1.lib \ + -DLIB_STATIC_APRUTIL1_LOC=%EXT_LIBS%\aprutil-1.lib \ + -DLIB_STATIC_YAML_CPP_LOC=%EXT_LIBS%\yaml-cpp.lib \ + -DLIB_STATIC_YAML_LOC=%EXT_LIBS%\yaml.lib \ + -DLIB_STATIC_Z_LOC=%EXT_LIBS%\z.lib \ + -DLIB_STATIC_CAPNP_LOC=%EXT_LIBS%\capnp.lib \ + -DLIB_STATIC_KJ_LOC=%EXT_LIBS%\kj.lib build_script: - - msbuild "C:\projects\nupic-core\build\scripts\gtest.vcxproj" /p:Configuration=Release /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" - - msbuild "C:\projects\nupic-core\build\scripts\nupic_core_solo.vcxproj" /p:Configuration=Release /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" - - msbuild "C:\projects\nupic-core\build\scripts\helloregion.vcxproj" /p:Configuration=Release /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" - - msbuild "C:\projects\nupic-core\build\scripts\prototest.vcxproj" /p:Configuration=Release /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" - - msbuild "C:\projects\nupic-core\build\scripts\py_region_test.vcxproj" /p:Configuration=Release /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" - - msbuild "C:\projects\nupic-core\build\scripts\cpp_region_test.vcxproj" /p:Configuration=Release /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" - - msbuild "C:\projects\nupic-core\build\scripts\unit_tests.vcxproj" /p:Configuration=Release /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" - - msbuild "C:\projects\nupic-core\build\scripts\Install.vcxproj" /p:Configuration=Release /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" + - cd %REPO_DIR%\build\scripts + - set MSBuildLogger="C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" + - set MSBuildOptions="/verbosity:minimal /p:Configuration=Release /logger:MSBuildLogger" + - msbuild gtest.vcxproj + - msbuild nupic_core_solo.vcxproj %MSBuildOptions% + - msbuild helloregion.vcxproj %MSBuildOptions% + - msbuild prototest.vcxproj %MSBuildOptions% + - msbuild py_region_test.vcxproj %MSBuildOptions% + - msbuild cpp_region_test.vcxproj %MSBuildOptions% + - msbuild unit_tests.vcxproj %MSBuildOptions% + - msbuild Install.vcxproj %MSBuildOptions% after_build: # Run the tests - cd C:\projects\nupic-core\build\release\bin - prototest 2>&1 - cpp_region_test 1 2>&1 - - unit_tests --gtest_output=xml:${PROJECT_BUILD_ARTIFACTS_DIR}/unit_tests_report.xml 2>&1 + - unit_tests --gtest_output=xml:unit_tests_report.xml 2>&1 - cd C:\projects\nupic-core\build\release - ps: >- - if($env:DEPLOY_BUILD -eq 1) { + if($env:DEPLOY_TO_NUGET -eq 1) { copy C:\projects\nupic-core\Package.nuspec . - nuget pack -version $env:APPVEYOR_BUILD_VERSION + nuget pack -version $env:APPVEYOR_REPO_COMMIT nuget push *.nupkg 30618afb-ecf6-4476-8e61-a5b823ad9892 - + move *.nupkg $env:PROJECT_BUILD_ARTIFACTS_DIR + } + if($env:DEPLOY_TO_S3 -eq 1) { Write-Host '7z a -ttar nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar .' - Start-Process -FilePath "7z" -ArgumentList "a -ttar nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar ." -Wait -Passthru + Start-Process -FilePath "7z" -ArgumentList "a -ttar -y -bd nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar ." -Wait -Passthru Write-Host '7z a -tgzip nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar' - Start-Process -FilePath "7z" -ArgumentList "a -tgzip nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar" -Wait -Passthru + Start-Process -FilePath "7z" -ArgumentList "a -tgzip -y -bd nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar" -Wait -Passthru + move nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz $env:PROJECT_BUILD_ARTIFACTS_DIR } - - cd C:\projects\nupic-core\build\release - - copy *.nupkg ${PROJECT_BUILD_ARTIFACTS_DIR} - - copy nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz ${PROJECT_BUILD_ARTIFACTS_DIR} +test: off artifacts: - path: build\artifacts -test: off +# to disable deployment deploy: off + +#deploy: + # Amazon S3 deployment provider settings + #- provider: S3 + # access_key_id: + # secure: AKIAIGHYSEHV3WFKOWNQ + # secret_access_key: + # secure: "pYsMDbNp8k2i0d9p5mf/9TlDzxt2FiiR1QJV7QUn+S2/r372VYdZaplL+s9ItVGCGFpAyKk7HXcwm//DKw/ZKb6UlDJm3Fph9m+3aDDIiVFNB7g1uro+Yg8nIGuV8qZEtIaHRtR1zOt1EufoR9dg1Mq8ryRggN9rrB0FvCxUZAQ=" + # bucket: "artifacts.numenta.org" + # folder: %PROJECT_BUILD_ARTIFACTS_DIR% + # artifact: + # set_public: false diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index aa02219279..fcbe27632e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -173,7 +173,7 @@ endif() # compiler specific settings here # if(${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC") - set(COMMON_COMPILE_FLAGS "/TP /Zc:wchar_t /Gm- /fp:precise /errorReport:prompt /W2 /WX- /GR /Gd /GS /Oy- /EHs /analyze- /nologo") + set(COMMON_COMPILE_FLAGS "/TP /Zc:wchar_t /Gm- /fp:precise /errorReport:prompt /W1 /WX- /GR /Gd /GS /Oy- /EHs /analyze- /nologo") set(COMMON_LINK_FLAGS "/NOLOGO /SAFESEH:NO /NODEFAULTLIB:LIBCMT") if("${BITNESS}" STREQUAL "32") set(COMMON_LINK_FLAGS "${COMMON_LINK_FLAGS} /MACHINE:X86") From f7acafab4b19d6ed3da36c207dbcad3ed3b7b05c Mon Sep 17 00:00:00 2001 From: Richard Crowder Date: Sat, 7 Mar 2015 14:01:57 +0000 Subject: [PATCH 038/100] REPO_DIR env var fix --- appveyor.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index ed40aba35d..a7ec95fb84 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,7 +3,7 @@ #---------------------------------# # version format -version: 0.3.0.%APPVEYOR_REPO_COMMIT% +version: 0.3.0.{build} #---------------------------------# # environment configuration # @@ -39,9 +39,9 @@ skip_commits: assembly_info: patch: true file: '**\AssemblyInfo.*' - assembly_version: "{version}" - assembly_file_version: "{version}" - assembly_informational_version: "{version}" + assembly_version: "%APPVEYOR_REPO_COMMIT%" + assembly_file_version: "%APPVEYOR_REPO_COMMIT%" + assembly_informational_version: "%APPVEYOR_REPO_COMMIT%" nuget: account_feed: true @@ -52,7 +52,7 @@ nuget: configuration: Release install: - - set REPO_DIR="c:\projects\nupic-core" + - set REPO_DIR=c:\projects\nupic-core - mkdir %REPO_DIR%\build\ - mkdir %REPO_DIR%\build\release - mkdir %REPO_DIR%\build\scripts @@ -65,7 +65,7 @@ install: - set PATH="C:\Program Files (x86)\MSBuild\14.0\Bin";%PATH% - echo %PATH% - cd %REPO_DIR%\build\scripts - - set EXT_LIBS="%REPO_DIR%\external\windows64\lib" + - set EXT_LIBS=%REPO_DIR%\external\windows64\lib - cmake %REPO_DIR%\src \ -G "Visual Studio 14 2015 Win64" -Wno-dev \ -DCMAKE_INSTALL_PREFIX=..\Release -DCMAKE_BUILD_TYPE=Release \ @@ -92,15 +92,15 @@ build_script: after_build: # Run the tests - - cd C:\projects\nupic-core\build\release\bin + - cd %REPO_DIR%\build\release\bin - prototest 2>&1 - cpp_region_test 1 2>&1 - unit_tests --gtest_output=xml:unit_tests_report.xml 2>&1 - - cd C:\projects\nupic-core\build\release + - cd %REPO_DIR%\build\release - ps: >- if($env:DEPLOY_TO_NUGET -eq 1) { - copy C:\projects\nupic-core\Package.nuspec . + copy $env:REPO_DIR\Package.nuspec . nuget pack -version $env:APPVEYOR_REPO_COMMIT nuget push *.nupkg 30618afb-ecf6-4476-8e61-a5b823ad9892 move *.nupkg $env:PROJECT_BUILD_ARTIFACTS_DIR From c667450219775c7a00d7e85d52e6898a5a4f5135 Mon Sep 17 00:00:00 2001 From: Richard Crowder Date: Sat, 7 Mar 2015 14:10:46 +0000 Subject: [PATCH 039/100] Multiline cmd fix --- appveyor.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index a7ec95fb84..ee2d047d18 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -66,15 +66,15 @@ install: - echo %PATH% - cd %REPO_DIR%\build\scripts - set EXT_LIBS=%REPO_DIR%\external\windows64\lib - - cmake %REPO_DIR%\src \ - -G "Visual Studio 14 2015 Win64" -Wno-dev \ - -DCMAKE_INSTALL_PREFIX=..\Release -DCMAKE_BUILD_TYPE=Release \ - -DLIB_STATIC_APR1_LOC=%EXT_LIBS%\apr-1.lib \ - -DLIB_STATIC_APRUTIL1_LOC=%EXT_LIBS%\aprutil-1.lib \ - -DLIB_STATIC_YAML_CPP_LOC=%EXT_LIBS%\yaml-cpp.lib \ - -DLIB_STATIC_YAML_LOC=%EXT_LIBS%\yaml.lib \ - -DLIB_STATIC_Z_LOC=%EXT_LIBS%\z.lib \ - -DLIB_STATIC_CAPNP_LOC=%EXT_LIBS%\capnp.lib \ + - cmake %REPO_DIR%\src + -G "Visual Studio 14 2015 Win64" -Wno-dev + -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=..\Release + -DLIB_STATIC_APR1_LOC=%EXT_LIBS%\apr-1.lib + -DLIB_STATIC_APRUTIL1_LOC=%EXT_LIBS%\aprutil-1.lib + -DLIB_STATIC_YAML_CPP_LOC=%EXT_LIBS%\yaml-cpp.lib + -DLIB_STATIC_YAML_LOC=%EXT_LIBS%\yaml.lib + -DLIB_STATIC_Z_LOC=%EXT_LIBS%\z.lib + -DLIB_STATIC_CAPNP_LOC=%EXT_LIBS%\capnp.lib -DLIB_STATIC_KJ_LOC=%EXT_LIBS%\kj.lib build_script: From 4bd74ce730c5f3840099e2792b066cda9411d33e Mon Sep 17 00:00:00 2001 From: Richard Crowder Date: Sat, 7 Mar 2015 14:26:21 +0000 Subject: [PATCH 040/100] MsBuild verbosity level fix --- appveyor.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index ee2d047d18..50ea91c50f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -80,15 +80,15 @@ install: build_script: - cd %REPO_DIR%\build\scripts - set MSBuildLogger="C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" - - set MSBuildOptions="/verbosity:minimal /p:Configuration=Release /logger:MSBuildLogger" - - msbuild gtest.vcxproj - - msbuild nupic_core_solo.vcxproj %MSBuildOptions% - - msbuild helloregion.vcxproj %MSBuildOptions% - - msbuild prototest.vcxproj %MSBuildOptions% - - msbuild py_region_test.vcxproj %MSBuildOptions% - - msbuild cpp_region_test.vcxproj %MSBuildOptions% - - msbuild unit_tests.vcxproj %MSBuildOptions% - - msbuild Install.vcxproj %MSBuildOptions% + - set MSBuildOptions=/v:m /p:Configuration=Release /logger:%MSBuildLogger% + - msbuild %MSBuildOptions% gtest.vcxproj + - msbuild %MSBuildOptions% nupic_core_solo.vcxproj + - msbuild %MSBuildOptions% helloregion.vcxproj + - msbuild %MSBuildOptions% prototest.vcxproj + - msbuild %MSBuildOptions% py_region_test.vcxproj + - msbuild %MSBuildOptions% cpp_region_test.vcxproj + - msbuild %MSBuildOptions% unit_tests.vcxproj + - msbuild %MSBuildOptions% Install.vcxproj after_build: # Run the tests From 81812df1cdd60dbed9374503fd672beef942dfc4 Mon Sep 17 00:00:00 2001 From: Richard Crowder Date: Sat, 7 Mar 2015 14:59:56 +0000 Subject: [PATCH 041/100] Quit Install project --- appveyor.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 50ea91c50f..ed095d7aee 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -88,6 +88,7 @@ build_script: - msbuild %MSBuildOptions% py_region_test.vcxproj - msbuild %MSBuildOptions% cpp_region_test.vcxproj - msbuild %MSBuildOptions% unit_tests.vcxproj + - set MSBuildOptions=/v:q /p:Configuration=Release /logger:%MSBuildLogger% - msbuild %MSBuildOptions% Install.vcxproj after_build: @@ -110,7 +111,8 @@ after_build: Start-Process -FilePath "7z" -ArgumentList "a -ttar -y -bd nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar ." -Wait -Passthru Write-Host '7z a -tgzip nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar' Start-Process -FilePath "7z" -ArgumentList "a -tgzip -y -bd nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar" -Wait -Passthru - move nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz $env:PROJECT_BUILD_ARTIFACTS_DIR + Write-Host 'move nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz $env:PROJECT_BUILD_ARTIFACTS_DIR' + Start-Process -FilePath "move" -ArgumentList "nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz $env:PROJECT_BUILD_ARTIFACTS_DIR" -Wait -Passthru } test: off From d47611ba677e2f4fc9e47c206d64acfeeec30584 Mon Sep 17 00:00:00 2001 From: Richard Crowder Date: Sat, 7 Mar 2015 15:32:01 +0000 Subject: [PATCH 042/100] Missing env var --- appveyor.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/appveyor.yml b/appveyor.yml index ed095d7aee..b3a144e39d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -99,6 +99,7 @@ after_build: - unit_tests --gtest_output=xml:unit_tests_report.xml 2>&1 - cd %REPO_DIR%\build\release + - set PROJECT_BUILD_ARTIFACTS_DIR=%REPO_DIR%\build\artifacts - ps: >- if($env:DEPLOY_TO_NUGET -eq 1) { copy $env:REPO_DIR\Package.nuspec . From 338c65bbb615b6eb2cc6f03ad19af43e7ff3919f Mon Sep 17 00:00:00 2001 From: Richard Crowder Date: Sat, 7 Mar 2015 16:07:53 +0000 Subject: [PATCH 043/100] Dropping Start-Process --- appveyor.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index b3a144e39d..11bfdc02a2 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -108,12 +108,9 @@ after_build: move *.nupkg $env:PROJECT_BUILD_ARTIFACTS_DIR } if($env:DEPLOY_TO_S3 -eq 1) { - Write-Host '7z a -ttar nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar .' - Start-Process -FilePath "7z" -ArgumentList "a -ttar -y -bd nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar ." -Wait -Passthru - Write-Host '7z a -tgzip nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar' - Start-Process -FilePath "7z" -ArgumentList "a -tgzip -y -bd nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar" -Wait -Passthru - Write-Host 'move nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz $env:PROJECT_BUILD_ARTIFACTS_DIR' - Start-Process -FilePath "move" -ArgumentList "nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz $env:PROJECT_BUILD_ARTIFACTS_DIR" -Wait -Passthru + 7z a -ttar -y -bd nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar . + 7z a -tgzip -y -bd nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar + move nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz $env:PROJECT_BUILD_ARTIFACTS_DIR } test: off From 58d51fa2d2520c6602a8257d1153d9487bd588c6 Mon Sep 17 00:00:00 2001 From: Richard Crowder Date: Sat, 7 Mar 2015 16:42:45 +0000 Subject: [PATCH 044/100] Alternative artifact path --- appveyor.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 11bfdc02a2..9394de06d1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -106,17 +106,19 @@ after_build: nuget pack -version $env:APPVEYOR_REPO_COMMIT nuget push *.nupkg 30618afb-ecf6-4476-8e61-a5b823ad9892 move *.nupkg $env:PROJECT_BUILD_ARTIFACTS_DIR + # set BUILD_ARTIFACTS=$env:PROJECT_BUILD_ARTIFACTS_DIR\nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz } if($env:DEPLOY_TO_S3 -eq 1) { 7z a -ttar -y -bd nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar . 7z a -tgzip -y -bd nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar move nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz $env:PROJECT_BUILD_ARTIFACTS_DIR + set BUILD_ARTIFACTS=$env:PROJECT_BUILD_ARTIFACTS_DIR\nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz } test: off artifacts: - - path: build\artifacts + - path: %BUILD_ARTIFACTS% # to disable deployment deploy: off From ce0af8761f54f365dc8e7c90529d278c8de4978b Mon Sep 17 00:00:00 2001 From: Richard Crowder Date: Sat, 7 Mar 2015 16:49:19 +0000 Subject: [PATCH 045/100] Yaml parse error fix --- appveyor.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 9394de06d1..e954e7e372 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -106,19 +106,19 @@ after_build: nuget pack -version $env:APPVEYOR_REPO_COMMIT nuget push *.nupkg 30618afb-ecf6-4476-8e61-a5b823ad9892 move *.nupkg $env:PROJECT_BUILD_ARTIFACTS_DIR - # set BUILD_ARTIFACTS=$env:PROJECT_BUILD_ARTIFACTS_DIR\nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz + set BUILD_ARTIFACTS=*.nupkg } if($env:DEPLOY_TO_S3 -eq 1) { 7z a -ttar -y -bd nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar . 7z a -tgzip -y -bd nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar move nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz $env:PROJECT_BUILD_ARTIFACTS_DIR - set BUILD_ARTIFACTS=$env:PROJECT_BUILD_ARTIFACTS_DIR\nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz + set BUILD_ARTIFACTS=nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz } test: off artifacts: - - path: %BUILD_ARTIFACTS% + - path: $env:PROJECT_BUILD_ARTIFACTS_DIR\$env:BUILD_ARTIFACTS # to disable deployment deploy: off From 9edb625493cffcdf53022ffac3b8290df2235812 Mon Sep 17 00:00:00 2001 From: Richard Crowder Date: Sat, 7 Mar 2015 17:18:21 +0000 Subject: [PATCH 046/100] Artifact path change --- appveyor.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index e954e7e372..813574674c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -106,19 +106,19 @@ after_build: nuget pack -version $env:APPVEYOR_REPO_COMMIT nuget push *.nupkg 30618afb-ecf6-4476-8e61-a5b823ad9892 move *.nupkg $env:PROJECT_BUILD_ARTIFACTS_DIR - set BUILD_ARTIFACTS=*.nupkg + set BUILD_ARTIFACTS=$env:PROJECT_BUILD_ARTIFACTS_DIR\*.nupkg } if($env:DEPLOY_TO_S3 -eq 1) { 7z a -ttar -y -bd nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar . 7z a -tgzip -y -bd nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar move nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz $env:PROJECT_BUILD_ARTIFACTS_DIR - set BUILD_ARTIFACTS=nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz + set BUILD_ARTIFACTS=$env:PROJECT_BUILD_ARTIFACTS_DIR\nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz } test: off artifacts: - - path: $env:PROJECT_BUILD_ARTIFACTS_DIR\$env:BUILD_ARTIFACTS + - path: $env:BUILD_ARTIFACTS # to disable deployment deploy: off From d498b1c2f6ded8048a7b242354c15818e9556dc8 Mon Sep 17 00:00:00 2001 From: Richard Crowder Date: Sat, 7 Mar 2015 18:13:53 +0000 Subject: [PATCH 047/100] Testing alt file paths --- appveyor.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 813574674c..97a6b86e66 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -118,7 +118,8 @@ after_build: test: off artifacts: - - path: $env:BUILD_ARTIFACTS + - path: %BUILD_ARTIFACTS% + - path: nupic_core-%APPVEYOR_REPO_COMMIT%-Windows64.tar.gz # to disable deployment deploy: off From 1524b7da0e36ed74d63055ff0e488b80fa71e63b Mon Sep 17 00:00:00 2001 From: Richard Crowder Date: Sat, 7 Mar 2015 18:19:10 +0000 Subject: [PATCH 048/100] Wildcarding artifacts --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 97a6b86e66..10328f4e06 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -118,8 +118,8 @@ after_build: test: off artifacts: - - path: %BUILD_ARTIFACTS% - - path: nupic_core-%APPVEYOR_REPO_COMMIT%-Windows64.tar.gz + - path: build\artifacts\*.nupkg + - path: build\artifacts\*.tar.gz # to disable deployment deploy: off From 1552e897808ce04388aaae2d82c43a72449b9377 Mon Sep 17 00:00:00 2001 From: Richard Crowder Date: Mon, 9 Mar 2015 17:45:16 +0000 Subject: [PATCH 049/100] Adding Numenta logo (32x32 PNG) [ci skip] --- Package.nuspec | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/Package.nuspec b/Package.nuspec index fb81ac7435..fe88b48a84 100644 --- a/Package.nuspec +++ b/Package.nuspec @@ -3,25 +3,23 @@ nupic.core $version$ - numenta - numenta + Numenta + Numenta https://github.com/numenta/nupic.core/blob/master/LICENSE.txt https://github.com/numenta/nupic.core - http://numenta.org/ + http://numenta.org/images/numenta-icon32.png true - -`NuPIC Core` contains core algorithms for NuPIC (the Numenta Platform for Intelligent Computing), implemented in C++. The source of this project is available at https://github.com/numenta/nupic - -For more information, see http://numenta.org or the https://github.com/numenta/nupic/wiki - -For information specific to `NuPIC Core`, please refer to: -https://github.com/numenta/nupic.core -https://github.com/numenta/nupic/wiki/NuPIC-Architecture - - Core algorithms for NuPIC - Pre-release for Windows + +`NuPIC Core` contains C++ source code for the Numenta Platform for Intelligent Computing (NuPIC). +For more information on Numenta and NuPIC, see http://numenta.org and https://github.com/numenta/nupic/wiki +The main NuPIC project is available at https://github.com/numenta/nupic +For information specific to the `NuPIC Core` library, please refer to: +https://github.com/numenta/nupic.core and https://github.com/numenta/nupic/wiki/NuPIC-Architecture + + Core algorithms for NuPIC + Windows 64-bit Release library (v140) Copyright (C) 2013-2015, Numenta, Inc - AI Intelligence Numenta nupic nupic.core + AI Intelligence AGI ML learning Numenta NuPIC nupic.core native HTM Hierarchical Temporal Memory CLA cortical Jeff Hawkins From 5de66441c91b7f600c0cbaf5c6a9243a49d015ac Mon Sep 17 00:00:00 2001 From: Richard Crowder Date: Tue, 10 Mar 2015 10:40:32 +0000 Subject: [PATCH 050/100] Tidy S3 deployment --- appveyor.yml | 53 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 10328f4e06..c15d17d2f8 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -68,7 +68,8 @@ install: - set EXT_LIBS=%REPO_DIR%\external\windows64\lib - cmake %REPO_DIR%\src -G "Visual Studio 14 2015 Win64" -Wno-dev - -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=..\Release + -DCMAKE_BUILD_TYPE=Release + -DCMAKE_INSTALL_PREFIX=..\Release -DLIB_STATIC_APR1_LOC=%EXT_LIBS%\apr-1.lib -DLIB_STATIC_APRUTIL1_LOC=%EXT_LIBS%\aprutil-1.lib -DLIB_STATIC_YAML_CPP_LOC=%EXT_LIBS%\yaml-cpp.lib @@ -89,7 +90,7 @@ build_script: - msbuild %MSBuildOptions% cpp_region_test.vcxproj - msbuild %MSBuildOptions% unit_tests.vcxproj - set MSBuildOptions=/v:q /p:Configuration=Release /logger:%MSBuildLogger% - - msbuild %MSBuildOptions% Install.vcxproj + - msbuild %MSBuildOptions% INSTALL.vcxproj after_build: # Run the tests @@ -100,38 +101,46 @@ after_build: - cd %REPO_DIR%\build\release - set PROJECT_BUILD_ARTIFACTS_DIR=%REPO_DIR%\build\artifacts + + # NOTE: S3 deployment takes precendence when setting BUILD_ARTIFACTS - ps: >- if($env:DEPLOY_TO_NUGET -eq 1) { copy $env:REPO_DIR\Package.nuspec . nuget pack -version $env:APPVEYOR_REPO_COMMIT nuget push *.nupkg 30618afb-ecf6-4476-8e61-a5b823ad9892 - move *.nupkg $env:PROJECT_BUILD_ARTIFACTS_DIR - set BUILD_ARTIFACTS=$env:PROJECT_BUILD_ARTIFACTS_DIR\*.nupkg + copy *.nupkg $env:PROJECT_BUILD_ARTIFACTS_DIR + Get-ChildItem .\*.nupkg | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name } } if($env:DEPLOY_TO_S3 -eq 1) { - 7z a -ttar -y -bd nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar . - 7z a -tgzip -y -bd nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar - move nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz $env:PROJECT_BUILD_ARTIFACTS_DIR - set BUILD_ARTIFACTS=$env:PROJECT_BUILD_ARTIFACTS_DIR\nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz + # This packages via CMakeList CPack settings (Tar.Gzip for SW upload) + # Calling 7z twice acheives the same result + # 7z a -ttar -y -bd nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar . + # 7z a -tgzip -y -bd nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar + msbuild %MSBuildOptions% PACKAGE.vcxproj + copy nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz $env:PROJECT_BUILD_ARTIFACTS_DIR + Get-ChildItem .\*.tar.gz | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name } } test: off artifacts: - - path: build\artifacts\*.nupkg - - path: build\artifacts\*.tar.gz + - path: '**\*.nupkg' # find all NuGet packages recursively + name: Nuget package -# to disable deployment -deploy: off + - path: '**\*.tar.gz' # find all Gz(ip) packages recursively + name: S3 package -#deploy: +deploy: # Amazon S3 deployment provider settings - #- provider: S3 - # access_key_id: - # secure: AKIAIGHYSEHV3WFKOWNQ - # secret_access_key: - # secure: "pYsMDbNp8k2i0d9p5mf/9TlDzxt2FiiR1QJV7QUn+S2/r372VYdZaplL+s9ItVGCGFpAyKk7HXcwm//DKw/ZKb6UlDJm3Fph9m+3aDDIiVFNB7g1uro+Yg8nIGuV8qZEtIaHRtR1zOt1EufoR9dg1Mq8ryRggN9rrB0FvCxUZAQ=" - # bucket: "artifacts.numenta.org" - # folder: %PROJECT_BUILD_ARTIFACTS_DIR% - # artifact: - # set_public: false + provider: S3 + access_key_id: AKIAIGHYSEHV3WFKOWNQ + secret_access_key: + secure: YhyY/6r2LNya8OZEmVOj+fv0lY5bBPqvy8MnsdLlptXa2uqwvezkCMNKiQ+wA+tOu+BS7VRRp86DhUqCpTZ3jUM2Mwdhud/Smq7D2X8vtZBiTVcOKfQcaypDE6Zu9Zp0SjMOSf6yiq6Ruu7D5QtZ4rtaq+5uPlvbgUXRZoZm0Po= + bucket: "artifacts.numenta.org" + region: us-west-2 + local-dir: "%PROJECT_BUILD_ARTIFACTS_DIR%" + upload-dir: "numenta/nupic.core" + skip_cleanup: true + # Deploying on master branch + on: + branch: master From e74e0e581c7c84f9f3d5ae86da4d70aa11d43cec Mon Sep 17 00:00:00 2001 From: Richard Crowder Date: Tue, 10 Mar 2015 11:22:20 +0000 Subject: [PATCH 051/100] Fixup PS env var --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index c15d17d2f8..b22ee18ec6 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -116,7 +116,7 @@ after_build: # Calling 7z twice acheives the same result # 7z a -ttar -y -bd nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar . # 7z a -tgzip -y -bd nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar - msbuild %MSBuildOptions% PACKAGE.vcxproj + msbuild $env:MSBuildOptions PACKAGE.vcxproj copy nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz $env:PROJECT_BUILD_ARTIFACTS_DIR Get-ChildItem .\*.tar.gz | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name } } From 0e596375c05b6a1ba1b142a6377333d10e75c99a Mon Sep 17 00:00:00 2001 From: Richard Crowder Date: Tue, 10 Mar 2015 11:48:58 +0000 Subject: [PATCH 052/100] Revert back to 7z for S3 archive building --- appveyor.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index b22ee18ec6..ae9a4d26b1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -113,10 +113,10 @@ after_build: } if($env:DEPLOY_TO_S3 -eq 1) { # This packages via CMakeList CPack settings (Tar.Gzip for SW upload) + # msbuild $env:MSBuildOptions PACKAGE.vcxproj # Calling 7z twice acheives the same result - # 7z a -ttar -y -bd nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar . - # 7z a -tgzip -y -bd nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar - msbuild $env:MSBuildOptions PACKAGE.vcxproj + 7z a -ttar -y -bd nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar . + 7z a -tgzip -y -bd nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar copy nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz $env:PROJECT_BUILD_ARTIFACTS_DIR Get-ChildItem .\*.tar.gz | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name } } From ed48c8029782f9fa4c6275d0ff1de3e10c0888c1 Mon Sep 17 00:00:00 2001 From: Richard Crowder Date: Tue, 10 Mar 2015 13:36:40 +0000 Subject: [PATCH 053/100] Full deploy ON --- appveyor.yml | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index ae9a4d26b1..024f48008c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -24,7 +24,7 @@ environment: # i.e. - COMPILER_FAMILY: GNU - COMPILER_FAMILY: MSVC DEPLOY_TO_S3: 1 - DEPLOY_TO_NUGET: 0 + DEPLOY_TO_NUGET: 1 skip_commits: # Add [av skip] to commit messages to skip AppVeyor building @@ -35,14 +35,6 @@ skip_commits: # build configuration # #---------------------------------# -# enable patching of AssemblyInfo.* files -assembly_info: - patch: true - file: '**\AssemblyInfo.*' - assembly_version: "%APPVEYOR_REPO_COMMIT%" - assembly_file_version: "%APPVEYOR_REPO_COMMIT%" - assembly_informational_version: "%APPVEYOR_REPO_COMMIT%" - nuget: account_feed: true project_feed: true @@ -102,13 +94,12 @@ after_build: - cd %REPO_DIR%\build\release - set PROJECT_BUILD_ARTIFACTS_DIR=%REPO_DIR%\build\artifacts - # NOTE: S3 deployment takes precendence when setting BUILD_ARTIFACTS + # NOTE: S3 deployment takes precedence when setting BUILD_ARTIFACTS - ps: >- if($env:DEPLOY_TO_NUGET -eq 1) { copy $env:REPO_DIR\Package.nuspec . nuget pack -version $env:APPVEYOR_REPO_COMMIT nuget push *.nupkg 30618afb-ecf6-4476-8e61-a5b823ad9892 - copy *.nupkg $env:PROJECT_BUILD_ARTIFACTS_DIR Get-ChildItem .\*.nupkg | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name } } if($env:DEPLOY_TO_S3 -eq 1) { @@ -117,7 +108,6 @@ after_build: # Calling 7z twice acheives the same result 7z a -ttar -y -bd nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar . 7z a -tgzip -y -bd nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar - copy nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz $env:PROJECT_BUILD_ARTIFACTS_DIR Get-ChildItem .\*.tar.gz | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name } } @@ -143,4 +133,5 @@ deploy: skip_cleanup: true # Deploying on master branch on: - branch: master + #branch: master + branch: 311-appveyor-s3-support From 0f554ec565d4cfd37bc77c7e892cb2833ac27d9c Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Tue, 10 Mar 2015 14:58:55 +0100 Subject: [PATCH 054/100] AppVeyor DEPLOY_BUILD workaround --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 4fb626e404..6db655bc40 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -35,7 +35,7 @@ environment: # - COMPILER_FAMILY: GNU # DEPLOY_BUILD: 0 - COMPILER_FAMILY: MSVC - DEPLOY_BUILD: 1 + DEPLOY_BUILD: 0 install: - mkdir C:\projects\nupic-core\build\ From a76141478b5a12e6b3f12d0933cd72f0c9655d5c Mon Sep 17 00:00:00 2001 From: Richard Crowder Date: Tue, 10 Mar 2015 14:24:52 +0000 Subject: [PATCH 055/100] Packaging fix for artifacts --- Package.nuspec | 2 +- appveyor.yml | 32 +++++++++++++++++--------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/Package.nuspec b/Package.nuspec index fe88b48a84..466e7e08ad 100644 --- a/Package.nuspec +++ b/Package.nuspec @@ -9,7 +9,7 @@ https://github.com/numenta/nupic.core http://numenta.org/images/numenta-icon32.png true - + `NuPIC Core` contains C++ source code for the Numenta Platform for Intelligent Computing (NuPIC). For more information on Numenta and NuPIC, see http://numenta.org and https://github.com/numenta/nupic/wiki The main NuPIC project is available at https://github.com/numenta/nupic diff --git a/appveyor.yml b/appveyor.yml index 024f48008c..f7f0a19ad9 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -100,7 +100,6 @@ after_build: copy $env:REPO_DIR\Package.nuspec . nuget pack -version $env:APPVEYOR_REPO_COMMIT nuget push *.nupkg 30618afb-ecf6-4476-8e61-a5b823ad9892 - Get-ChildItem .\*.nupkg | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name } } if($env:DEPLOY_TO_S3 -eq 1) { # This packages via CMakeList CPack settings (Tar.Gzip for SW upload) @@ -108,10 +107,12 @@ after_build: # Calling 7z twice acheives the same result 7z a -ttar -y -bd nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar . 7z a -tgzip -y -bd nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar - Get-ChildItem .\*.tar.gz | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name } } test: off + +# to disable deployment +#deploy: off artifacts: - path: '**\*.nupkg' # find all NuGet packages recursively @@ -121,17 +122,18 @@ artifacts: name: S3 package deploy: + # Amazon S3 deployment provider settings - provider: S3 - access_key_id: AKIAIGHYSEHV3WFKOWNQ - secret_access_key: - secure: YhyY/6r2LNya8OZEmVOj+fv0lY5bBPqvy8MnsdLlptXa2uqwvezkCMNKiQ+wA+tOu+BS7VRRp86DhUqCpTZ3jUM2Mwdhud/Smq7D2X8vtZBiTVcOKfQcaypDE6Zu9Zp0SjMOSf6yiq6Ruu7D5QtZ4rtaq+5uPlvbgUXRZoZm0Po= - bucket: "artifacts.numenta.org" - region: us-west-2 - local-dir: "%PROJECT_BUILD_ARTIFACTS_DIR%" - upload-dir: "numenta/nupic.core" - skip_cleanup: true - # Deploying on master branch - on: - #branch: master - branch: 311-appveyor-s3-support + - provider: S3 + access_key_id: AKIAIGHYSEHV3WFKOWNQ + secret_access_key: + secure: YhyY/6r2LNya8OZEmVOj+fv0lY5bBPqvy8MnsdLlptXa2uqwvezkCMNKiQ+wA+tOu+BS7VRRp86DhUqCpTZ3jUM2Mwdhud/Smq7D2X8vtZBiTVcOKfQcaypDE6Zu9Zp0SjMOSf6yiq6Ruu7D5QtZ4rtaq+5uPlvbgUXRZoZm0Po= + bucket: "artifacts.numenta.org" + region: us-west-2 + local-dir: "%PROJECT_BUILD_ARTIFACTS_DIR%" + upload-dir: "numenta/nupic.core" + skip_cleanup: true + # Deploying on master branch + on: + #branch: master + branch: 311-appveyor-s3-support From 587f95ae163547be8361261df24a238ae45cf679 Mon Sep 17 00:00:00 2001 From: Richard Crowder Date: Tue, 10 Mar 2015 14:27:36 +0000 Subject: [PATCH 056/100] Damn tab --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index f7f0a19ad9..18ae086c72 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -133,7 +133,7 @@ deploy: local-dir: "%PROJECT_BUILD_ARTIFACTS_DIR%" upload-dir: "numenta/nupic.core" skip_cleanup: true - # Deploying on master branch + # Deploying on master branch on: #branch: master branch: 311-appveyor-s3-support From 49e7e21bb9a67275936f6902fcec9938c6bddd4e Mon Sep 17 00:00:00 2001 From: Richard Crowder Date: Tue, 10 Mar 2015 15:04:29 +0000 Subject: [PATCH 057/100] Nuget requires a dotted version number --- appveyor.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 18ae086c72..6e232bb020 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -98,15 +98,15 @@ after_build: - ps: >- if($env:DEPLOY_TO_NUGET -eq 1) { copy $env:REPO_DIR\Package.nuspec . - nuget pack -version $env:APPVEYOR_REPO_COMMIT + nuget pack -version $env:APPVEYOR_BUILD_VERSION nuget push *.nupkg 30618afb-ecf6-4476-8e61-a5b823ad9892 } if($env:DEPLOY_TO_S3 -eq 1) { # This packages via CMakeList CPack settings (Tar.Gzip for SW upload) # msbuild $env:MSBuildOptions PACKAGE.vcxproj - # Calling 7z twice acheives the same result + # Calling 7z twice achieves the same result 7z a -ttar -y -bd nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar . - 7z a -tgzip -y -bd nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar + 7z a -tgzip -y -bd ..\..\nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar } test: off @@ -125,7 +125,8 @@ deploy: # Amazon S3 deployment provider settings - provider: S3 - access_key_id: AKIAIGHYSEHV3WFKOWNQ + access_key_id: + secure: AKIAIGHYSEHV3WFKOWNQ secret_access_key: secure: YhyY/6r2LNya8OZEmVOj+fv0lY5bBPqvy8MnsdLlptXa2uqwvezkCMNKiQ+wA+tOu+BS7VRRp86DhUqCpTZ3jUM2Mwdhud/Smq7D2X8vtZBiTVcOKfQcaypDE6Zu9Zp0SjMOSf6yiq6Ruu7D5QtZ4rtaq+5uPlvbgUXRZoZm0Po= bucket: "artifacts.numenta.org" From 0b55e051333718a2d2c468369e773898a17f995d Mon Sep 17 00:00:00 2001 From: Richard Crowder Date: Tue, 10 Mar 2015 15:40:06 +0000 Subject: [PATCH 058/100] Only push new package to nuget, no deploy step --- appveyor.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 6e232bb020..1e14f10b9b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -100,6 +100,7 @@ after_build: copy $env:REPO_DIR\Package.nuspec . nuget pack -version $env:APPVEYOR_BUILD_VERSION nuget push *.nupkg 30618afb-ecf6-4476-8e61-a5b823ad9892 + # NOTE: Push to nuget is here, rather than normal AV deployment } if($env:DEPLOY_TO_S3 -eq 1) { # This packages via CMakeList CPack settings (Tar.Gzip for SW upload) @@ -115,9 +116,6 @@ test: off #deploy: off artifacts: - - path: '**\*.nupkg' # find all NuGet packages recursively - name: Nuget package - - path: '**\*.tar.gz' # find all Gz(ip) packages recursively name: S3 package From f46534dac2b8831719776f5dc204470e3b362199 Mon Sep 17 00:00:00 2001 From: Richard Crowder Date: Wed, 11 Mar 2015 20:34:08 +0000 Subject: [PATCH 059/100] Separating out LogItems for CI --- appveyor.yml | 81 ++++++++++++++++++---------- src/nupic/os/Directory.cpp | 2 +- src/nupic/os/OSWin.cpp | 2 +- src/nupic/utils/LogItem.cpp | 10 +++- src/nupic/utils/LogItem.hpp | 2 +- src/nupic/utils/LoggingException.cpp | 9 +++- 6 files changed, 72 insertions(+), 34 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 1e14f10b9b..e013d558ff 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,6 +5,25 @@ # version format version: 0.3.0.{build} +#branches: +# only: +# - master +# except: +# - gh-pages + +environment: + matrix: + # Must add CLang, or GCC + # i.e. - COMPILER_FAMILY: GNU + - COMPILER_FAMILY: MSVC + DEPLOY_TO_S3: 0 + DEPLOY_TO_NUGET: 0 + +skip_commits: + # Add [av skip] to commit messages to skip AppVeyor building + # Add [ci skip] to skip Travis and AppVeyor building + message: /\[av skip\]/ + #---------------------------------# # environment configuration # #---------------------------------# @@ -18,19 +37,6 @@ init: # clone directory clone_folder: c:\projects\nupic-core -environment: - matrix: - # Must add either GCC or CLang here - # i.e. - COMPILER_FAMILY: GNU - - COMPILER_FAMILY: MSVC - DEPLOY_TO_S3: 1 - DEPLOY_TO_NUGET: 1 - -skip_commits: - # Add [av skip] to commit messages to skip AppVeyor building - # Add [ci skip] to skip Travis and AppVeyor building - message: /\[av skip\]/ - #---------------------------------# # build configuration # #---------------------------------# @@ -45,17 +51,20 @@ configuration: Release install: - set REPO_DIR=c:\projects\nupic-core + - set NUPIC_DEPLOYMENT_BUILD=1 + - mkdir %REPO_DIR%\build\ - mkdir %REPO_DIR%\build\release - mkdir %REPO_DIR%\build\scripts - cd %REPO_DIR%\build\scripts + # Need at least version 3.1.0 for the VS 2015 generator - ps: Start-FileDownload 'http://www.cmake.org/files/v3.1/cmake-3.1.0-win32-x86.zip' - ps: Write-Host '7z x cmake-3.1.0-win32-x86.zip' - ps: Start-Process -FilePath "7z" -ArgumentList "x -y cmake-3.1.0-win32-x86.zip" -Wait -Passthru - set PATH="%REPO_DIR%\build\scripts\cmake-3.1.0-win32-x86\bin";%PATH% - set PATH="C:\Program Files (x86)\MSBuild\14.0\Bin";%PATH% - - echo %PATH% + - cd %REPO_DIR%\build\scripts - set EXT_LIBS=%REPO_DIR%\external\windows64\lib - cmake %REPO_DIR%\src @@ -72,8 +81,19 @@ install: build_script: - cd %REPO_DIR%\build\scripts + + - ps: >- + $root = $env:APPVEYOR_BUILD_FOLDER + $versionStr = $env:APPVEYOR_BUILD_VERSION + Write-Host $root + Write-Host "Setting Package.nuspec version tag to $versionStr" + $content = (Get-Content $root\Package.nuspec) + $content = $content -replace '\$version\$',$versionStr + $content | Out-File $root\Package.nuspec + - set MSBuildLogger="C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" - set MSBuildOptions=/v:m /p:Configuration=Release /logger:%MSBuildLogger% + - msbuild %MSBuildOptions% gtest.vcxproj - msbuild %MSBuildOptions% nupic_core_solo.vcxproj - msbuild %MSBuildOptions% helloregion.vcxproj @@ -85,39 +105,45 @@ build_script: - msbuild %MSBuildOptions% INSTALL.vcxproj after_build: - # Run the tests - cd %REPO_DIR%\build\release\bin - - prototest 2>&1 - - cpp_region_test 1 2>&1 - - unit_tests --gtest_output=xml:unit_tests_report.xml 2>&1 + + # Run the tests + - prototest + - cpp_region_test 1 + - unit_tests --gtest_output=xml:unit_tests_report.xml + # transform the JUnit-style xml report to html + #- xsltproc %REPO_DIR%\doc\xunit.xslt unit_tests_report.xml > unit_tests_report.html - cd %REPO_DIR%\build\release - set PROJECT_BUILD_ARTIFACTS_DIR=%REPO_DIR%\build\artifacts - # NOTE: S3 deployment takes precedence when setting BUILD_ARTIFACTS - ps: >- if($env:DEPLOY_TO_NUGET -eq 1) { copy $env:REPO_DIR\Package.nuspec . + nuget pack -version $env:APPVEYOR_BUILD_VERSION + nuget push *.nupkg 30618afb-ecf6-4476-8e61-a5b823ad9892 # NOTE: Push to nuget is here, rather than normal AV deployment + } + if($env:DEPLOY_TO_S3 -eq 1) { # This packages via CMakeList CPack settings (Tar.Gzip for SW upload) # msbuild $env:MSBuildOptions PACKAGE.vcxproj - # Calling 7z twice achieves the same result + 7z a -ttar -y -bd nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar . + 7z a -tgzip -y -bd ..\..\nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar - } -test: off - -# to disable deployment -#deploy: off + } artifacts: - path: '**\*.tar.gz' # find all Gz(ip) packages recursively - name: S3 package + +# To disable the deploy step uncomment the line below +#deploy: off +test: off deploy: @@ -134,5 +160,4 @@ deploy: skip_cleanup: true # Deploying on master branch on: - #branch: master - branch: 311-appveyor-s3-support + branch: master \ No newline at end of file diff --git a/src/nupic/os/Directory.cpp b/src/nupic/os/Directory.cpp index 7394fd926f..4da516c33e 100644 --- a/src/nupic/os/Directory.cpp +++ b/src/nupic/os/Directory.cpp @@ -255,7 +255,7 @@ namespace nupic if (!success) { NTA_THROW << "Directory::create -- failed to create directory \"" << path << "\".\n" - << "OS Error: " << OS::getErrorMessage(); + << "Msg: " << OS::getErrorMessage(); } } diff --git a/src/nupic/os/OSWin.cpp b/src/nupic/os/OSWin.cpp index 8198d131d8..4924b17b2a 100755 --- a/src/nupic/os/OSWin.cpp +++ b/src/nupic/os/OSWin.cpp @@ -87,7 +87,7 @@ std::string OS::getErrorMessageFromErrorCode(int errorCode) errMessage.write((LPSTR) lpMsgBuf, msgLen); } else { - errMessage << "Error code: " << errorCode; + errMessage << "Code: " << errorCode; } LocalFree(lpMsgBuf); diff --git a/src/nupic/utils/LogItem.cpp b/src/nupic/utils/LogItem.cpp index 400aed1265..069d08a038 100644 --- a/src/nupic/utils/LogItem.cpp +++ b/src/nupic/utils/LogItem.cpp @@ -60,18 +60,24 @@ LogItem::~LogItem() case error: slevel = "ERROR:"; break; + case ci: + // Continuous Integration services e.g. Travis, AppVeyor + // The use of the word "error" in stdout can fail builds + slevel = "CI: "; + break; default: slevel = "Unknown: "; break; } - if (ostream_ == nullptr) ostream_ = &(std::cout); (*ostream_) << slevel << " " << msg_.str(); - if (level_ == error) + + if (level_ == error || level_ == ci) (*ostream_) << " [" << filename_ << " line " << lineno_ << "]"; + (*ostream_) << std::endl; } diff --git a/src/nupic/utils/LogItem.hpp b/src/nupic/utils/LogItem.hpp index 5c598a59b7..797293cf9d 100644 --- a/src/nupic/utils/LogItem.hpp +++ b/src/nupic/utils/LogItem.hpp @@ -47,7 +47,7 @@ namespace nupic { class LogItem { public: - typedef enum {debug, info, warn, error} LogLevel; + typedef enum {debug, ci, info, warn, error} LogLevel; /** * Record information to be logged */ diff --git a/src/nupic/utils/LoggingException.cpp b/src/nupic/utils/LoggingException.cpp index 369e5d4391..48153ff248 100644 --- a/src/nupic/utils/LoggingException.cpp +++ b/src/nupic/utils/LoggingException.cpp @@ -34,9 +34,16 @@ LoggingException::~LoggingException() throw() if (!alreadyLogged_) { // Let LogItem do the work for us. This code is a bit complex // because LogItem was designed to be used from a logging macro - auto li = new LogItem(filename_.c_str(), lineno_, LogItem::error); + LogItem *li; + + if (::getenv("NUPIC_DEPLOYMENT_BUILD")) + li = new LogItem(filename_.c_str(), lineno_, LogItem::LogLevel::ci); + else + li = new LogItem(filename_.c_str(), lineno_, LogItem::error); + li->stream() << getMessage(); delete li; + alreadyLogged_ = true; } } From a386a799d50bb02f3f08091015ec62cb2d52f4d8 Mon Sep 17 00:00:00 2001 From: Richard Crowder Date: Wed, 11 Mar 2015 20:50:57 +0000 Subject: [PATCH 060/100] Space out the yaml PowerShell --- appveyor.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index e013d558ff..872518ef43 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -84,11 +84,17 @@ build_script: - ps: >- $root = $env:APPVEYOR_BUILD_FOLDER + $versionStr = $env:APPVEYOR_BUILD_VERSION + Write-Host $root + Write-Host "Setting Package.nuspec version tag to $versionStr" + $content = (Get-Content $root\Package.nuspec) + $content = $content -replace '\$version\$',$versionStr + $content | Out-File $root\Package.nuspec - set MSBuildLogger="C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" From c3486663866f28c435cec57ac4812b1cb50acd25 Mon Sep 17 00:00:00 2001 From: Richard Crowder Date: Wed, 11 Mar 2015 20:52:27 +0000 Subject: [PATCH 061/100] Yaml tabs --- appveyor.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 872518ef43..65c8ef3063 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -84,17 +84,17 @@ build_script: - ps: >- $root = $env:APPVEYOR_BUILD_FOLDER - + $versionStr = $env:APPVEYOR_BUILD_VERSION - + Write-Host $root - + Write-Host "Setting Package.nuspec version tag to $versionStr" - + $content = (Get-Content $root\Package.nuspec) - + $content = $content -replace '\$version\$',$versionStr - + $content | Out-File $root\Package.nuspec - set MSBuildLogger="C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" From 35d3521e31f9f6cfc554dc1eb71128ef89118977 Mon Sep 17 00:00:00 2001 From: Richard Crowder Date: Wed, 11 Mar 2015 21:27:29 +0000 Subject: [PATCH 062/100] Back to single solution build --- appveyor.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 65c8ef3063..5de6a56e92 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -100,13 +100,7 @@ build_script: - set MSBuildLogger="C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" - set MSBuildOptions=/v:m /p:Configuration=Release /logger:%MSBuildLogger% - - msbuild %MSBuildOptions% gtest.vcxproj - - msbuild %MSBuildOptions% nupic_core_solo.vcxproj - - msbuild %MSBuildOptions% helloregion.vcxproj - - msbuild %MSBuildOptions% prototest.vcxproj - - msbuild %MSBuildOptions% py_region_test.vcxproj - - msbuild %MSBuildOptions% cpp_region_test.vcxproj - - msbuild %MSBuildOptions% unit_tests.vcxproj + - msbuild %MSBuildOptions% nupic_core.sln - set MSBuildOptions=/v:q /p:Configuration=Release /logger:%MSBuildLogger% - msbuild %MSBuildOptions% INSTALL.vcxproj From 9884c8556daa33772e5c20d1e7a6ef4fb4d22fb1 Mon Sep 17 00:00:00 2001 From: Richard Crowder Date: Wed, 11 Mar 2015 22:12:00 +0000 Subject: [PATCH 063/100] Full deploy --- appveyor.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 5de6a56e92..b7efd657c8 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -16,8 +16,8 @@ environment: # Must add CLang, or GCC # i.e. - COMPILER_FAMILY: GNU - COMPILER_FAMILY: MSVC - DEPLOY_TO_S3: 0 - DEPLOY_TO_NUGET: 0 + DEPLOY_TO_S3: 1 + DEPLOY_TO_NUGET: 1 skip_commits: # Add [av skip] to commit messages to skip AppVeyor building @@ -107,10 +107,6 @@ build_script: after_build: - cd %REPO_DIR%\build\release\bin - # Run the tests - - prototest - - cpp_region_test 1 - - unit_tests --gtest_output=xml:unit_tests_report.xml # transform the JUnit-style xml report to html #- xsltproc %REPO_DIR%\doc\xunit.xslt unit_tests_report.xml > unit_tests_report.html @@ -160,4 +156,5 @@ deploy: skip_cleanup: true # Deploying on master branch on: - branch: master \ No newline at end of file + branch: master + branch: 311-appveyor-s3-support \ No newline at end of file From 726c6eb08b4e2bc0f1d33880c3b7db2a0a2729d1 Mon Sep 17 00:00:00 2001 From: Richard Crowder Date: Wed, 11 Mar 2015 22:13:14 +0000 Subject: [PATCH 064/100] Branch deploy --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index b7efd657c8..de0d3c6e1e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -156,5 +156,5 @@ deploy: skip_cleanup: true # Deploying on master branch on: - branch: master + #branch: master branch: 311-appveyor-s3-support \ No newline at end of file From b9a6798589133450d46a91e339c8cd2f730ea156 Mon Sep 17 00:00:00 2001 From: Richard Crowder Date: Wed, 11 Mar 2015 22:47:37 +0000 Subject: [PATCH 065/100] S3 deployment off [av skip] --- appveyor.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index de0d3c6e1e..18a1779c13 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -16,7 +16,7 @@ environment: # Must add CLang, or GCC # i.e. - COMPILER_FAMILY: GNU - COMPILER_FAMILY: MSVC - DEPLOY_TO_S3: 1 + DEPLOY_TO_S3: 0 DEPLOY_TO_NUGET: 1 skip_commits: @@ -154,7 +154,5 @@ deploy: local-dir: "%PROJECT_BUILD_ARTIFACTS_DIR%" upload-dir: "numenta/nupic.core" skip_cleanup: true - # Deploying on master branch on: - #branch: master - branch: 311-appveyor-s3-support \ No newline at end of file + branch: master \ No newline at end of file From ba05c01b5f5d6f806668b398e20f6563deb5601c Mon Sep 17 00:00:00 2001 From: Richard Crowder Date: Fri, 13 Mar 2015 21:13:11 +0000 Subject: [PATCH 066/100] Adding shallow git cloning and clone depth of 50 --- appveyor.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 18a1779c13..73f0f46493 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -17,7 +17,7 @@ environment: # i.e. - COMPILER_FAMILY: GNU - COMPILER_FAMILY: MSVC DEPLOY_TO_S3: 0 - DEPLOY_TO_NUGET: 1 + DEPLOY_TO_NUGET: 0 skip_commits: # Add [av skip] to commit messages to skip AppVeyor building @@ -34,8 +34,9 @@ os: Visual Studio 2015 CTP init: - git config --global core.autocrlf input -# clone directory clone_folder: c:\projects\nupic-core +clone_depth: 50 +shallow_clone: true #---------------------------------# # build configuration # From 67307f0e0638236455718cbd74fbe2fe33dee2a4 Mon Sep 17 00:00:00 2001 From: Richard Crowder Date: Fri, 13 Mar 2015 21:46:18 +0000 Subject: [PATCH 067/100] Always deploy to S3 --- appveyor.yml | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 73f0f46493..9707afa6f5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -16,7 +16,6 @@ environment: # Must add CLang, or GCC # i.e. - COMPILER_FAMILY: GNU - COMPILER_FAMILY: MSVC - DEPLOY_TO_S3: 0 DEPLOY_TO_NUGET: 0 skip_commits: @@ -106,11 +105,6 @@ build_script: - msbuild %MSBuildOptions% INSTALL.vcxproj after_build: - - cd %REPO_DIR%\build\release\bin - - # transform the JUnit-style xml report to html - #- xsltproc %REPO_DIR%\doc\xunit.xslt unit_tests_report.xml > unit_tests_report.html - - cd %REPO_DIR%\build\release - set PROJECT_BUILD_ARTIFACTS_DIR=%REPO_DIR%\build\artifacts @@ -125,15 +119,12 @@ after_build: } - if($env:DEPLOY_TO_S3 -eq 1) { - # This packages via CMakeList CPack settings (Tar.Gzip for SW upload) - # msbuild $env:MSBuildOptions PACKAGE.vcxproj + # This packages via CMakeList CPack settings (Tar.Gzip for SW upload) + # msbuild $env:MSBuildOptions PACKAGE.vcxproj - 7z a -ttar -y -bd nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar . + 7z a -ttar -y -bd nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar . - 7z a -tgzip -y -bd ..\..\nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar - - } + 7z a -tgzip -y -bd ..\..\nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar artifacts: - path: '**\*.tar.gz' # find all Gz(ip) packages recursively From ee0ce9897844dd6e8fffd594e984fd34161344e0 Mon Sep 17 00:00:00 2001 From: Richard Crowder Date: Fri, 13 Mar 2015 22:23:09 +0000 Subject: [PATCH 068/100] Reverting LogItem CI redirect by using "ERR" --- appveyor.yml | 17 ++++++++--------- src/nupic/os/Directory.cpp | 17 ++++++++--------- src/nupic/os/OSWin.cpp | 2 +- src/nupic/utils/LogItem.cpp | 9 ++------- src/nupic/utils/LogItem.hpp | 2 +- src/nupic/utils/LoggingException.cpp | 8 +------- 6 files changed, 21 insertions(+), 34 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 9707afa6f5..0f9a80dbe9 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,11 +5,12 @@ # version format version: 0.3.0.{build} -#branches: -# only: -# - master -# except: -# - gh-pages +branches: + only: + - master + + except: + - gh-pages environment: matrix: @@ -104,6 +105,8 @@ build_script: - set MSBuildOptions=/v:q /p:Configuration=Release /logger:%MSBuildLogger% - msbuild %MSBuildOptions% INSTALL.vcxproj +test: off + after_build: - cd %REPO_DIR%\build\release - set PROJECT_BUILD_ARTIFACTS_DIR=%REPO_DIR%\build\artifacts @@ -129,10 +132,6 @@ after_build: artifacts: - path: '**\*.tar.gz' # find all Gz(ip) packages recursively -# To disable the deploy step uncomment the line below -#deploy: off -test: off - deploy: # Amazon S3 deployment provider settings diff --git a/src/nupic/os/Directory.cpp b/src/nupic/os/Directory.cpp index 4da516c33e..5ce25501bf 100644 --- a/src/nupic/os/Directory.cpp +++ b/src/nupic/os/Directory.cpp @@ -54,7 +54,7 @@ namespace nupic #if defined(NTA_OS_WINDOWS) wchar_t wcwd[APR_PATH_MAX]; DWORD res = ::GetCurrentDirectoryW(APR_PATH_MAX, wcwd); - NTA_CHECK(res > 0) << "Couldn't get current working directory. Error code: " + NTA_CHECK(res > 0) << "Couldn't get current working directory. OS msg: " << OS::getErrorMessage(); std::string cwd = Path::unicodeToUtf8(std::wstring(wcwd)); return cwd; @@ -62,7 +62,7 @@ namespace nupic char cwd[APR_PATH_MAX]; cwd[0] = '\0'; char * res = ::getcwd(cwd, APR_PATH_MAX); - NTA_CHECK(res != nullptr) << "Couldn't get current working directory. Error code: " << errno; + NTA_CHECK(res != nullptr) << "Couldn't get current working directory. OS num: " << errno; return std::string(cwd); #endif } @@ -148,7 +148,7 @@ namespace nupic NTA_THROW << "Directory::removeTree() failed. " << "Unable to remove the file'" << fullPath << "'. " - << "OS error description: " << OS::getErrorMessage(); + << "OS msg: " << OS::getErrorMessage(); } } } @@ -255,7 +255,7 @@ namespace nupic if (!success) { NTA_THROW << "Directory::create -- failed to create directory \"" << path << "\".\n" - << "Msg: " << OS::getErrorMessage(); + << "OS msg: " << OS::getErrorMessage(); } } @@ -277,7 +277,7 @@ namespace nupic std::string absolutePath = Path::makeAbsolute(path); res = ::apr_dir_open(&handle_, absolutePath.c_str(), pool_); NTA_CHECK(res == 0) << "Can't open directory " << path - << ". Error code: " << APR_TO_OS_ERROR(res); + << ". OS num: " << APR_TO_OS_ERROR(res); } Iterator::~Iterator() @@ -285,7 +285,7 @@ namespace nupic apr_status_t res = ::apr_dir_close(handle_); ::apr_pool_destroy(pool_); NTA_CHECK(res == 0) << "Couldn't close directory." - << " Error code: " << APR_TO_OS_ERROR(res); + << " OS num: " << APR_TO_OS_ERROR(res); } void Iterator::reset() @@ -293,7 +293,7 @@ namespace nupic apr_status_t res = ::apr_dir_rewind(handle_); NTA_CHECK(res == 0) << "Couldn't reset directory iterator." - << " Error code: " << APR_TO_OS_ERROR(res); + << " OS num: " << APR_TO_OS_ERROR(res); } Entry * Iterator::next(Entry & e) @@ -309,7 +309,7 @@ namespace nupic { NTA_CHECK(res == APR_INCOMPLETE) << "Couldn't read next dir entry." - << " Error code: " << APR_TO_OS_ERROR(res); + << " OS num: " << APR_TO_OS_ERROR(res); NTA_CHECK(((e.valid & wanted) | APR_FINFO_LINK) == wanted) << "Couldn't retrieve all fields. Valid mask=" << e.valid; } @@ -328,4 +328,3 @@ namespace nupic } } } - diff --git a/src/nupic/os/OSWin.cpp b/src/nupic/os/OSWin.cpp index 4924b17b2a..51f5776ac8 100755 --- a/src/nupic/os/OSWin.cpp +++ b/src/nupic/os/OSWin.cpp @@ -87,7 +87,7 @@ std::string OS::getErrorMessageFromErrorCode(int errorCode) errMessage.write((LPSTR) lpMsgBuf, msgLen); } else { - errMessage << "Code: " << errorCode; + errMessage << "code: " << errorCode; } LocalFree(lpMsgBuf); diff --git a/src/nupic/utils/LogItem.cpp b/src/nupic/utils/LogItem.cpp index 069d08a038..6d4e5bd091 100644 --- a/src/nupic/utils/LogItem.cpp +++ b/src/nupic/utils/LogItem.cpp @@ -58,12 +58,7 @@ LogItem::~LogItem() slevel = "INFO: "; break; case error: - slevel = "ERROR:"; - break; - case ci: - // Continuous Integration services e.g. Travis, AppVeyor - // The use of the word "error" in stdout can fail builds - slevel = "CI: "; + slevel = "ERR:"; break; default: slevel = "Unknown: "; @@ -75,7 +70,7 @@ LogItem::~LogItem() (*ostream_) << slevel << " " << msg_.str(); - if (level_ == error || level_ == ci) + if (level_ == error) (*ostream_) << " [" << filename_ << " line " << lineno_ << "]"; (*ostream_) << std::endl; diff --git a/src/nupic/utils/LogItem.hpp b/src/nupic/utils/LogItem.hpp index 797293cf9d..5c598a59b7 100644 --- a/src/nupic/utils/LogItem.hpp +++ b/src/nupic/utils/LogItem.hpp @@ -47,7 +47,7 @@ namespace nupic { class LogItem { public: - typedef enum {debug, ci, info, warn, error} LogLevel; + typedef enum {debug, info, warn, error} LogLevel; /** * Record information to be logged */ diff --git a/src/nupic/utils/LoggingException.cpp b/src/nupic/utils/LoggingException.cpp index 48153ff248..e47b7e582d 100644 --- a/src/nupic/utils/LoggingException.cpp +++ b/src/nupic/utils/LoggingException.cpp @@ -34,13 +34,7 @@ LoggingException::~LoggingException() throw() if (!alreadyLogged_) { // Let LogItem do the work for us. This code is a bit complex // because LogItem was designed to be used from a logging macro - LogItem *li; - - if (::getenv("NUPIC_DEPLOYMENT_BUILD")) - li = new LogItem(filename_.c_str(), lineno_, LogItem::LogLevel::ci); - else - li = new LogItem(filename_.c_str(), lineno_, LogItem::error); - + LogItem *li = new LogItem(filename_.c_str(), lineno_, LogItem::error); li->stream() << getMessage(); delete li; From 9919ced6d352052d8d6d6c17bff8ba25d9d70b55 Mon Sep 17 00:00:00 2001 From: Richard Crowder Date: Sat, 14 Mar 2015 14:49:37 +0000 Subject: [PATCH 069/100] Formatting --- README.md | 4 ++- external/windows64/README.md | 64 +++++++++++++++++++----------------- 2 files changed, 37 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 3c2c38c7c5..88d65dd4da 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,10 @@ This repository contains the C++ source code for the Numenta Platform for Intell ## Build and test NuPIC Core: Important notes: - * For developers (contributing to NuPIC Core) please follow the [C++ Development Workflow steps](https://github.com/numenta/nupic.core/wiki/C++-Development-Workflow). + * For developers (contributing to NuPIC Core) please follow the [Development Workflow](https://github.com/numenta/nupic.core/wiki/Development-Workflow) steps. * `$NUPIC_CORE` is the current location of the repository that you downloaded from GitHub. + * Platform specific Readme.md text files exist in some `external/` subdirectories + * See the main [wiki](https://github.com/numenta/nupic.core/wiki) for more build notes ### Using command line diff --git a/external/windows64/README.md b/external/windows64/README.md index 62a2a7496b..3f155a4368 100644 --- a/external/windows64/README.md +++ b/external/windows64/README.md @@ -4,58 +4,62 @@ The core library of NuPIC uses a CMake based system to define build characterist Two environment variables must be setup before building the core; -- NUPIC_CORE_SOURCE points to the root of the core directories, and -- NUPIC_CORE points to an installation directory. +- `NUPIC_CORE_SOURCE` points to the root of the core directories, and +- `NUPIC_CORE` points to an installation directory. The following applications are required to rebuilt the core and external libraries; - [Microsoft Visual Studio Ultimate 2015 Preview](http://www.visualstudio.com/en-us/downloads/visual-studio-2015-downloads-vs) ([installer webpage](http://go.microsoft.com/?linkid=9863611&clcid=0x409)) - [CMake](http://www.cmake.org/) (version 3.1 onwards to get the Visual Studio 2015 generator). -The following table shows the CMake-GUI settings for the core library. Using these table settings the %NUPIC_CORE% directory could equal the CMAKE_INSTALL_PREFIX directory. +The following table shows the CMake-GUI settings for the core library. Using these table settings the `%NUPIC_CORE%` directory could equal the CMAKE_INSTALL_PREFIX directory. | Name | Value | |:---- |:----- | -| Source code | %NUPIC_CORE_SOURCE%/src | -| Binaries | %NUPIC_CORE_SOURCE%/build/scripts | -| CMAKE_INSTALL_PREFIX | %NUPIC_CORE_SOURCE%/build/release | +| Source code | `%NUPIC_CORE_SOURCE%/src` | +| Binaries | `%NUPIC_CORE_SOURCE%/build/scripts` | +| CMAKE_INSTALL_PREFIX | `%NUPIC_CORE_SOURCE%/build/release` | -Note: The %NUPIC_CORE_SOURCE%/.gitignore file has a rule that ignores any directory called build/ from Git. Making it a convenient place to store build dependencies. +The `%NUPIC_CORE_SOURCE%/build/scripts/nupic_core.sln` solution (v140 platform toolset) has an ALL_BUILD project that can rebuild the x64 Release version of the core library and test programs. As well as running the cpp_region test and unit tests. -The %NUPIC_CORE_SOURCE%/build/scripts/nupic_core.sln solution (v140 platform toolset) has an ALL_BUILD project that can rebuild the x64 Release version of the core library and test programs. As well as running the cpp_region test and unit tests. +**Notes:** +* The `%NUPIC_CORE_SOURCE%/.gitignore` file has a rule that ignores any directory called `build/` from Git. A convenient place to store build dependencies, such as debug libraries, as branches change and CMake-GUI is rerun. +* The `ZERO_CHECK` project is used by CMake during the build process. +* With this being a CMake based cross-platform project, any changes made to project configurations from within Visual Studio must be carried across to the `src\CMakeLists.txt` file to become permanent changes. +* Consequently, any changes made to `src\CMakeLists.txt` requires a _(re)_-run of CMake-GUI to configure and generate new Visual Studio project files with those changes. Make sure that Visual Studio is not running when this step occurs. -> At the time of writing; Two of the 12 projects fail when building the solution via Visual Studio or msbuild. The tests_cpp_region and tests_unit Utility projects both fail. Even though full debugging of the contained test projects all pass. The %NUPIC_CORE_SOURCE%/appveyor.yml file outlines script to unwrap the solution into individual msbuild steps, and which test programs to execute. +The INSTALL project has to be built separately. External libraries (x64 release) are stored in the Git repository, and packaged into the deployed version. When the ALL_BUILD project completes, a separate run of the INSTALL project copies the binaries, header, and library files into the `%NUPIC_CORE%` directory. -The INSTALL project has to be built separately. External libraries (x64 release) are stored in the Git repository, and packaged into the deployed version. When the ALL_BUILD project completes, a separate run of the INSTALL project copies the binaries, header, and library files into the %NUPIC_CORE% directory. +The PACKAGE project implements the `src\CmakeLists.txt` file CPack packaging instructions. It takes the post-INSTALL release files and makes a tape archive file (tar format) that is then compressed (gzip format) into a single file. The `%NUPIC_CORE_SOURCE%\appveyor.yml` file shows an alternative method for library deployment using the 7z application. The NuPIC core library file is split into two files; -- %NUPIC_CORE%/lib/nupic_core_solo.lib contains _only_ the core library -- %NUPIC_CORE%/lib/nupic_core.lib contains the core and support libraries +- `%NUPIC_CORE%/lib/nupic_core_solo.lib` contains _only_ the core library +- `%NUPIC_CORE%/lib/nupic_core.lib` contains the core and support libraries ## External libraries -The Core library depends on a handful of external libraries that are distributed within the download package. The Windows x64 version of these libraries can be found in %NUPIC_CORE_SOURCE%\external\windows64\lib The following can be used as a guide if you require changes to these pre-built libraries, such as creating Debug versions. +The Core library depends on a handful of external libraries that are distributed within the download package. The Windows x64 version of these libraries can be found in `%NUPIC_CORE_SOURCE%\external\windows64\lib` The following can be used as a guide if you require changes to these pre-built libraries, such as creating Debug versions. ### Obtaining the library sources -The following libraries are embedded into the %NUPIC_CORE%/lib/nupic_core library. +The following libraries are embedded into the `%NUPIC_CORE%/lib/nupic_core` library. | Library | Version | Filename | Website | |:------- |:------- |:-------- | :------- | -| APR | **1.5.1** | apr-1.5.1-win32-src.zip | https://apr.apache.org/ | -| Apr Util | **1.5.4** | apr-util-1.5.4-win32-src.zip | https://apr.apache.org/ | -| Apr Iconv | **1.2.1** | apr-iconv-1.2.1-win32-src-r2.zip | https://apr.apache.org/ | -| Cap'n Proto | **0.5.0** | capnproto-c++-win32-0.5.0.zip | https://capnproto.org | -| Yaml | **0.1.5** | yaml-0.1.5.tar.gz | http://pyyaml.org/wiki/LibYAML | -| Yaml Cpp | **0.3.0** | yaml-cpp-0.3.0.tar.gz | https://code.google.com/p/yaml-cpp/ | -| Z Lib | **1.2.8** | zlib-1.2.8.tar.gz | http://www.zlib.net/ | +| APR | **1.5.1** | apr-**1.5.1**-win32-src.zip | https://apr.apache.org/ | +| Apr Util | **1.5.4** | apr-util-**1.5.4**-win32-src.zip | https://apr.apache.org/ | +| Apr Iconv | **1.2.1** | apr-iconv-**1.2.1**-win32-src-r2.zip | https://apr.apache.org/ | +| Cap'n Proto | **0.5.0** | capnproto-c++-win32-**0.5.0**.zip | https://capnproto.org | +| Yaml | **0.1.5** | yaml-**0.1.5**.tar.gz | http://pyyaml.org/wiki/LibYAML | +| Yaml Cpp | **0.3.0** | yaml-cpp-**0.3.0**.tar.gz | https://code.google.com/p/yaml-cpp/ | +| Z Lib | **1.2.8** | zlib-**1.2.8**.tar.gz | http://www.zlib.net/ | -Extract them all into %NUPIC_CORE_SOURCE%/build directory. You may need to un-nest some of the directories, e.g. apr-1.5.1/apr-1.5.1/... to apr-1.5.1/... APR expects certain directory names, rename the following directories; +Extract them all into `%NUPIC_CORE_SOURCE%/build` directory. You may need to un-nest some of the directories, e.g. `apr-1.5.1/apr-1.5.1/...` to `apr-1.5.1/...` APR expects certain directory names, rename the following directories; -apr-1.5.1 to apr -apr-iconv-1.2.1 to apr-iconv -apr-util-1.5.4 to apr-util +`apr-1.5.1` to `apr` +`apr-iconv-1.2.1` to `apr-iconv` +`apr-util-1.5.4` to `apr-util` ### Building the external libraries @@ -65,7 +69,7 @@ If a solution contains an Install project, the install scripts are placed inside > cmake.exe -DBUILD_TYPE=Release -P cmake_install.cmake -This implies that your %PATH% environment variable has a directory to the cmake.exe (typically "C:\Program Files (x86)\CMake\bin"). +This implies that your `%PATH%` environment variable has a directory to the cmake.exe (typically "C:\Program Files (x86)\CMake\bin"). ### Apache Portable Runtime (APR) @@ -75,7 +79,7 @@ apr.dsw and aprutil.dsw workspace files can be imported into Visual Studio 2015. Download version **0.5.0** from https://capnproto.org/capnproto-c++-win32-0.5.0.zip -The three executable files found in %NUPIC_CORE_SOURCE%\build\capnproto-tools-win32-0.5.0 should match the corresponding %NUPIC_CORE_SOURCE%\external\windows64\bin executable files, and tie in with the external capnp and kj common include directories. +The three executable files found in `%NUPIC_CORE_SOURCE%\build\capnproto-tools-win32-0.5.0` should match the corresponding `%NUPIC_CORE_SOURCE%\external\windows64\bin` executable files, and tie in with the external capnp and kj common include directories. Install instructions can be found at https://capnproto.org/install.html This is an example Visual Studio Command Prompt line to invoke cmake and generator a solution and project files for Cap'n Proto. @@ -87,12 +91,12 @@ Building the test programs may halt a full build. But enough will be built for a ### Yaml -A valid libyaml.sln solution file can be found in directory yaml-0.1.5\win32\vs2008 A new x64 platform solution can be added to it once imported into Visual Studio 2015. We only need to build the yaml project from this solution. +A valid libyaml.sln solution file can be found in directory `yaml-0.1.5\win32\vs2008` A new x64 platform solution can be added to it once imported into Visual Studio 2015. We only need to build the yaml project from this solution. ### Yaml-cpp -In CMake-GUI %NUPIC_CORE_SOURCE%/build/yaml-cpp/ can be used for Source and Build directories. Make sure that MSVC_SHARED_RT is **ticked**, and BUILD_SHARED_LIBS and MSVC_STHREADED_RT are both **not ticked**. When building the solution you may need to `#include ` in src\ostream_wrapper.cpp +In CMake-GUI `%NUPIC_CORE_SOURCE%/build/yaml-cpp/` can be used for Source and Build directories. Make sure that MSVC_SHARED_RT is **ticked**, and BUILD_SHARED_LIBS and MSVC_STHREADED_RT are both **not ticked**. When building the solution you may need to `#include ` in `src\ostream_wrapper.cpp` ### Z Lib -In zlib-1.2.8\contrib\vstudio there are solutions for Visual Studio 9, 10, and 11. The vc11 solution can be used with Visual Studio 2015. A x64 platform solution can be added to this imported solution. The zlibstat is the library we need to overwite z.lib in directory %NUPIC_CORE_SOURCE%/external/windows64/lib +In `zlib-1.2.8\contrib\vstudio` there are solutions for Visual Studio 9, 10, and 11. The vc11 solution can be used with Visual Studio 2015. A x64 platform solution can be added to this imported solution. The zlibstat is the library we need to overwite z.lib in directory `%NUPIC_CORE_SOURCE%/external/windows64/lib` From b2f415babe5e737f7a60981e0fb4aa27a8750b50 Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Mon, 16 Mar 2015 14:19:29 +0100 Subject: [PATCH 070/100] profilig docs for Valgrind/Callgrind --- src/examples/algorithms/Readme.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/examples/algorithms/Readme.md b/src/examples/algorithms/Readme.md index 7efdaf56a8..a37d436d90 100644 --- a/src/examples/algorithms/Readme.md +++ b/src/examples/algorithms/Readme.md @@ -14,4 +14,19 @@ More classes should be added as they are ported (Encoders, Classifier, Anomaly, For ongoing optimization goals, we need a simple but complete code to run benchmarks and profile. You can easily change the constants (`EPOCHS, DIM,...`) and try this code on your branch. +### Using `valgrind` profiler (for memory, #calls usage) + +Steps to profile methods' execution time with `valgrind`'s extension `callgrind`: + +* You will need to install the `valgrind` profiling tool +* Compile your C++ source with debug info (`-g`) and (optionally) optimizations on. Eg.: +``` +CC=gcc-4.8 CXX=g++-4.8 cmake -DCMAKE_BUILD_TYPE=Debug ../../src -DCMAKE_INSTALL_PREFIX=../release -DCMAKE_EXPORT_COMPILE_COMMANDS=O && time make -j4 +``` +* run desired program with (valgrind/callgrind)[http://valgrind.org/docs/manual/cl-manual.html]: +``` +valgrind --tool=callgrind ./hello_sp_tp +``` +it will generate file `callgrind.out.` which can be viewed in a graphical tool (eg. `KCacheGrind` for Ubuntu and others) or proccessed on +command line: `callgrind_annotate callgrind.out.` From 7c55ac78e6dac5e100a098a3656ea65a7888bee6 Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Mon, 16 Mar 2015 14:25:17 +0100 Subject: [PATCH 071/100] whitespace --- src/CMakeLists.txt | 1 - src/examples/algorithms/HelloSP_TP.cpp | 4 +-- src/nupic/algorithms/SpatialPooler.cpp | 34 +++++++++++++------------- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 084ee6d7d3..03d1555dec 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -460,7 +460,6 @@ set_target_properties(${EXECUTABLE_PROTOTEST} PROPERTIES LINK_FLAGS "${COMMON_LINK_FLAGS}") add_dependencies(${EXECUTABLE_PROTOTEST} ${COMMON_LIBS}) -# TODO better way to build examples? # # Setup HelloSP_TP example # diff --git a/src/examples/algorithms/HelloSP_TP.cpp b/src/examples/algorithms/HelloSP_TP.cpp index 112f5e89b8..1d4ba3cb0f 100644 --- a/src/examples/algorithms/HelloSP_TP.cpp +++ b/src/examples/algorithms/HelloSP_TP.cpp @@ -65,12 +65,12 @@ const UInt EPOCHS = pow(10, 4); // number of iterations (calls to SP/TP compute( Timer stopwatch(true); //run - for (UInt e=0; e< EPOCHS; e++) { + for (UInt e = 0; e < EPOCHS; e++) { generate(input.begin(), input.end(), RandomNumber01); fill(outSP.begin(), outSP.end(), 0); sp.compute(input.data(), true, outSP.data()); - for (UInt i=0; i< DIM; i++) { + for (UInt i = 0; i < DIM; i++) { rIn[i] = (Real)(outSP[i]); } diff --git a/src/nupic/algorithms/SpatialPooler.cpp b/src/nupic/algorithms/SpatialPooler.cpp index a24ad381ff..84c08166f3 100644 --- a/src/nupic/algorithms/SpatialPooler.cpp +++ b/src/nupic/algorithms/SpatialPooler.cpp @@ -119,23 +119,23 @@ SpatialPooler::SpatialPooler() } SpatialPooler::SpatialPooler(vector inputDimensions, - vector columnDimensions, - UInt potentialRadius, - Real potentialPct, - bool globalInhibition, - Real localAreaDensity, - UInt numActiveColumnsPerInhArea, - UInt stimulusThreshold, - Real synPermInactiveDec, - Real synPermActiveInc, - Real synPermConnected, - Real minPctOverlapDutyCycles, - Real minPctActiveDutyCycles, - UInt dutyCyclePeriod, - Real maxBoost, - Int seed, - UInt spVerbosity, - bool wrapAround) : SpatialPooler::SpatialPooler() + vector columnDimensions, + UInt potentialRadius, + Real potentialPct, + bool globalInhibition, + Real localAreaDensity, + UInt numActiveColumnsPerInhArea, + UInt stimulusThreshold, + Real synPermInactiveDec, + Real synPermActiveInc, + Real synPermConnected, + Real minPctOverlapDutyCycles, + Real minPctActiveDutyCycles, + UInt dutyCyclePeriod, + Real maxBoost, + Int seed, + UInt spVerbosity, + bool wrapAround) : SpatialPooler::SpatialPooler() { initialize( inputDimensions, columnDimensions, From 129b3bf0c23cfa3e8e2eb598c2e2fbecfbd37ea8 Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Mon, 16 Mar 2015 19:10:27 +0100 Subject: [PATCH 072/100] Revert "TP deault constructor same params as py.TP" This reverts commit a347e954baf070318d2576c626e4f26e79ba062a. Conflicts: src/nupic/algorithms/Cells4.hpp --- src/nupic/algorithms/Cells4.hpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/nupic/algorithms/Cells4.hpp b/src/nupic/algorithms/Cells4.hpp index 6b8a60db66..379712c644 100644 --- a/src/nupic/algorithms/Cells4.hpp +++ b/src/nupic/algorithms/Cells4.hpp @@ -394,12 +394,11 @@ namespace nupic { /** * Default constructor needed when lifting from persistence. */ - Cells4(UInt nColumns =500, - UInt nCellsPerCol =10, - UInt activationThreshold =12, - UInt minThreshold =8, - UInt newSynapseCount =15, - UInt segUpdateValidDuration =5, + Cells4(UInt nColumns =0, UInt nCellsPerCol =0, + UInt activationThreshold =1, + UInt minThreshold =1, + UInt newSynapseCount =1, + UInt segUpdateValidDuration =1, Real permInitial =.5, Real permConnected =.8, Real permMax =1, @@ -407,8 +406,8 @@ namespace nupic { Real permInc =.1, Real globalDecay =0, bool doPooling =false, - int seed =42, - bool initFromCpp =true, + int seed =-1, + bool initFromCpp =false, bool checkSynapseConsistency =false); @@ -417,12 +416,11 @@ namespace nupic { * This also called when lifting from persistence. */ void - initialize(UInt nColumns =500, - UInt nCellsPerCol =10, - UInt activationThreshold =12, - UInt minThreshold =8, - UInt newSynapseCount =15, - UInt segUpdateValidDuration =5, + initialize(UInt nColumns =0, UInt nCellsPerCol =0, + UInt activationThreshold =1, + UInt minThreshold =1, + UInt newSynapseCount =1, + UInt segUpdateValidDuration =1, Real permInitial =.5, Real permConnected =.8, Real permMax =1, From f9c78411f00087c78e6b7f38e9217f62f4c48273 Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Mon, 16 Mar 2015 19:16:06 +0100 Subject: [PATCH 073/100] nit --- src/examples/algorithms/{Readme.md => README.md} | 1 - 1 file changed, 1 deletion(-) rename src/examples/algorithms/{Readme.md => README.md} (99%) diff --git a/src/examples/algorithms/Readme.md b/src/examples/algorithms/README.md similarity index 99% rename from src/examples/algorithms/Readme.md rename to src/examples/algorithms/README.md index a37d436d90..ca382d5299 100644 --- a/src/examples/algorithms/Readme.md +++ b/src/examples/algorithms/README.md @@ -29,4 +29,3 @@ valgrind --tool=callgrind ./hello_sp_tp ``` it will generate file `callgrind.out.` which can be viewed in a graphical tool (eg. `KCacheGrind` for Ubuntu and others) or proccessed on command line: `callgrind_annotate callgrind.out.` - From b29ce95b253fcff28923b59884f7275430313fbc Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Mon, 16 Mar 2015 19:45:25 +0100 Subject: [PATCH 074/100] hopefully last nit ;) --- src/nupic/algorithms/SpatialPooler.cpp | 36 +++++++++++++------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/nupic/algorithms/SpatialPooler.cpp b/src/nupic/algorithms/SpatialPooler.cpp index 84c08166f3..66e3e4fa6d 100644 --- a/src/nupic/algorithms/SpatialPooler.cpp +++ b/src/nupic/algorithms/SpatialPooler.cpp @@ -137,24 +137,24 @@ SpatialPooler::SpatialPooler(vector inputDimensions, UInt spVerbosity, bool wrapAround) : SpatialPooler::SpatialPooler() { - initialize( inputDimensions, - columnDimensions, - potentialRadius, - potentialPct, - globalInhibition, - localAreaDensity, - numActiveColumnsPerInhArea, - stimulusThreshold, - synPermInactiveDec, - synPermActiveInc, - synPermConnected, - minPctOverlapDutyCycles, - minPctActiveDutyCycles, - dutyCyclePeriod, - maxBoost, - seed, - spVerbosity, - wrapAround); + initialize(inputDimensions, + columnDimensions, + potentialRadius, + potentialPct, + globalInhibition, + localAreaDensity, + numActiveColumnsPerInhArea, + stimulusThreshold, + synPermInactiveDec, + synPermActiveInc, + synPermConnected, + minPctOverlapDutyCycles, + minPctActiveDutyCycles, + dutyCyclePeriod, + maxBoost, + seed, + spVerbosity, + wrapAround); } From 0651d9d9b5b6c5cf01bb70c4bc04ccb583455c03 Mon Sep 17 00:00:00 2001 From: Richard Crowder Date: Thu, 19 Mar 2015 20:45:32 +0000 Subject: [PATCH 075/100] An example CMake GUI settings capture PNG --- external/windows64/CMake GUI settings.PNG | Bin 0 -> 94012 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 external/windows64/CMake GUI settings.PNG diff --git a/external/windows64/CMake GUI settings.PNG b/external/windows64/CMake GUI settings.PNG new file mode 100644 index 0000000000000000000000000000000000000000..c2c349554d69984b0bce5484ce448c45425b9474 GIT binary patch literal 94012 zcmW(+by!pH-~K9sv~)?xsBJVzNGi>!F}BeSDy4)dpn?LUn~iQZU;`;d0SW06BpiZD zcXtcC`@Prod3NGC+aKrJxt}{eCmL$3OGnK`{ojB8(dp}H!T$U2CW17?DJe*27+xjv zk~TN|V7eOrRSt2lkq&M>d1UnHzyE3yY5qBqla8sp^(_7V`;Wfkf8$2a^D>wJ{=3HM zYdwMo*ljl7e#2srx6-#cwLP`Hl`zSpKBhW0wKLbO8}OWO+IlX0mpAbJEg4FNb^-o} z0aQ0q9#RVM$2PI2?5bS<{&6_*Cp+`&%;gnhCc+ZOwA!qjojbI6a2ej$8`UdjdiEiz ztm0+n#XleCM0HrltA)Ru8(TzESYeYfGU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{(!$T+jIB5f+u%7?V|P&{-Le%wWcaJwh^QAB7E=E+cAeUXF$l0X!7&dT4cvpgj_B{nlUE&{eJ=f ppXUE_*hT-#x6VdOOlfw3{~vCblBJ|CRC53T002ovPDHLkV1lN-<+cC- literal 0 HcmV?d00001 From a9412251886b86ff0a2a967ab3730416cea39542 Mon Sep 17 00:00:00 2001 From: Scott Purdy Date: Mon, 6 Apr 2015 13:32:49 -0700 Subject: [PATCH 076/100] Updates FastCLAClassifierTest to use googletest. --- src/CMakeLists.txt | 1 - .../unit/algorithms/FastCLAClassifierTest.cpp | 59 +++++++++---------- .../unit/algorithms/FastCLAClassifierTest.hpp | 55 ----------------- 3 files changed, 29 insertions(+), 86 deletions(-) delete mode 100644 src/test/unit/algorithms/FastCLAClassifierTest.hpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 03d1555dec..9dfd2b6518 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -531,7 +531,6 @@ add_custom_target(tests_unit set(TEST_HEADERS test/unit/algorithms/CondProbTableTest.hpp test/unit/algorithms/ConnectionsTest.hpp - test/unit/algorithms/FastCLAClassifierTest.hpp test/unit/algorithms/FlatSpatialPoolerTest.hpp test/unit/algorithms/NearestNeighborUnitTest.hpp test/unit/algorithms/SpatialPoolerTest.hpp diff --git a/src/test/unit/algorithms/FastCLAClassifierTest.cpp b/src/test/unit/algorithms/FastCLAClassifierTest.cpp index dddfdfe06b..96c7322dd1 100644 --- a/src/test/unit/algorithms/FastCLAClassifierTest.cpp +++ b/src/test/unit/algorithms/FastCLAClassifierTest.cpp @@ -24,26 +24,22 @@ * Implementation of unit tests for NearestNeighbor */ -#include +#include #include #include #include #include #include -#include "FastCLAClassifierTest.hpp" using namespace std; +using namespace nupic; using namespace nupic::algorithms::cla_classifier; -namespace nupic { +namespace +{ - void FastCLAClassifierTest::RunTests() - { - testBasic(); - } - - void FastCLAClassifierTest::testBasic() + TEST(FastCLAClassifierTest, Basic) { vector steps; steps.push_back(1); @@ -74,33 +70,36 @@ namespace nupic { if (it->first == -1) { // The -1 key is used for the actual values - TESTEQUAL2("already found key -1 in classifier result", - false, foundMinus1); + ASSERT_EQ(false, foundMinus1) + << "already found key -1 in classifier result"; foundMinus1 = true; - TESTEQUAL2("Expected five buckets since it has only seen bucket 4 " - "(so it has buckets 0-4).", (long unsigned int)5, it->second->size()); - TEST2("Incorrect actual value for bucket 4", - fabs(it->second->at(4) - 34.7) < 0.000001); + ASSERT_EQ((long unsigned int)5, it->second->size()) + << "Expected five buckets since it has only seen bucket 4 (so it " + << "has buckets 0-4)."; + ASSERT_TRUE(fabs(it->second->at(4) - 34.7) < 0.000001) + << "Incorrect actual value for bucket 4"; } else if (it->first == 1) { // Check the one-step prediction - TESTEQUAL2("already found key 1 in classifier result", false, found1); + ASSERT_EQ(false, found1) + << "already found key 1 in classifier result"; found1 = true; - TESTEQUAL2("expected five bucket predictions", (long unsigned int)5, it->second->size()); - TEST2("incorrect prediction for bucket 0", - fabs(it->second->at(0) - 0.2) < 0.000001); - TEST2("incorrect prediction for bucket 1", - fabs(it->second->at(1) - 0.2) < 0.000001); - TEST2("incorrect prediction for bucket 2", - fabs(it->second->at(2) - 0.2) < 0.000001); - TEST2("incorrect prediction for bucket 3", - fabs(it->second->at(3) - 0.2) < 0.000001); - TEST2("incorrect prediction for bucket 4", - fabs(it->second->at(4) - 0.2) < 0.000001); + ASSERT_EQ((long unsigned int)5, it->second->size()) + << "expected five bucket predictions"; + ASSERT_LT(fabs(it->second->at(0) - 0.2), 0.000001) + << "incorrect prediction for bucket 0"; + ASSERT_LT(fabs(it->second->at(1) - 0.2), 0.000001) + << "incorrect prediction for bucket 1"; + ASSERT_LT(fabs(it->second->at(2) - 0.2), 0.000001) + << "incorrect prediction for bucket 2"; + ASSERT_LT(fabs(it->second->at(3) - 0.2), 0.000001) + << "incorrect prediction for bucket 3"; + ASSERT_LT(fabs(it->second->at(4) - 0.2), 0.000001) + << "incorrect prediction for bucket 4"; } } - TESTEQUAL2("key -1 not found in classifier result", true, foundMinus1); - TESTEQUAL2("key 1 not found in classifier result", true, found1); + ASSERT_TRUE(foundMinus1) << "key -1 not found in classifier result"; + ASSERT_TRUE(found1) << "key 1 not found in classifier result"; } } -} // end namespace nupic +} // end namespace diff --git a/src/test/unit/algorithms/FastCLAClassifierTest.hpp b/src/test/unit/algorithms/FastCLAClassifierTest.hpp deleted file mode 100644 index ec4ccde6b0..0000000000 --- a/src/test/unit/algorithms/FastCLAClassifierTest.hpp +++ /dev/null @@ -1,55 +0,0 @@ -/* --------------------------------------------------------------------- - * Numenta Platform for Intelligent Computing (NuPIC) - * Copyright (C) 2013, Numenta, Inc. Unless you have an agreement - * with Numenta, Inc., for a separate license for this software code, the - * following terms and conditions apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 3 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses. - * - * http://numenta.org/licenses/ - * --------------------------------------------------------------------- - */ - -/** @file - * Definitions for FastCLAClassifierTest - * - * The FastCLAClassifier class is primarily tested in the Python unit tests - * but this file provides an easy way to check for memory leaks. - */ - -#ifndef NTA_FAST_CLA_CLASSIFIER_TEST -#define NTA_FAST_CLA_CLASSIFIER_TEST - -#include - -namespace nupic -{ - - class FastCLAClassifierTest : public Tester - { - public: - FastCLAClassifierTest() {} - - virtual ~FastCLAClassifierTest() {} - - // Run all appropriate tests. - virtual void RunTests() override; - - private: - void testBasic(); - - }; // end class FastCLAClassifierTest - -} // end namespace nupic - -#endif // NTA_FAST_CLA_CLASSIFIER_TEST From ab1acb64443f96c73a2d4390817503e5691d7ffb Mon Sep 17 00:00:00 2001 From: Matthew Taylor Date: Wed, 8 Apr 2015 11:07:42 -0700 Subject: [PATCH 077/100] Removed libstdc++ license file. This is because libstdc++ is deployed as a part of gcc (https://gcc.gnu.org/libstdc++/), so we are not bound to it's GPL license as defined by the GCC Runtime Library Exception: https://www.gnu.org/licenses/gcc-exception-3.1.html. --- external/licenses/LICENSE.libstdc++-4.0.3.txt | 370 ------------------ 1 file changed, 370 deletions(-) delete mode 100644 external/licenses/LICENSE.libstdc++-4.0.3.txt diff --git a/external/licenses/LICENSE.libstdc++-4.0.3.txt b/external/licenses/LICENSE.libstdc++-4.0.3.txt deleted file mode 100644 index 2630a3ae10..0000000000 --- a/external/licenses/LICENSE.libstdc++-4.0.3.txt +++ /dev/null @@ -1,370 +0,0 @@ -// Copyright (C) 1997-1999, 2000 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 2, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, -// USA. - -// As a special exception, you may use this file as part of a free software -// library without restriction. Specifically, if other files instantiate -// templates or use macros or inline functions from this file, or you compile -// this file and link it with other files to produce an executable, this -// file does not by itself cause the resulting executable to be covered by -// the GNU General Public License. This exception does not however -// invalidate any other reasons why the executable file might be covered by -// the GNU General Public License. - - -============================ - - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. From f9d85d81cca5bb604bae2fc422b2526d27a79aa1 Mon Sep 17 00:00:00 2001 From: Matthew Taylor Date: Wed, 8 Apr 2015 11:18:06 -0700 Subject: [PATCH 078/100] Removed logilab license info. Logilab packages were included initially because pylint required them. We've removed the dependency on pylint, so these should be removed as well. --- .../licenses/LICENSE.logilab-astng-0.24.3.txt | 510 ------------------ .../LICENSE.logilab-common-0.59.1.txt | 510 ------------------ 2 files changed, 1020 deletions(-) delete mode 100644 external/licenses/LICENSE.logilab-astng-0.24.3.txt delete mode 100644 external/licenses/LICENSE.logilab-common-0.59.1.txt diff --git a/external/licenses/LICENSE.logilab-astng-0.24.3.txt b/external/licenses/LICENSE.logilab-astng-0.24.3.txt deleted file mode 100644 index 2d2d780e60..0000000000 --- a/external/licenses/LICENSE.logilab-astng-0.24.3.txt +++ /dev/null @@ -1,510 +0,0 @@ - - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations -below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it -becomes a de-facto standard. To achieve this, non-free programs must -be allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control -compilation and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at least - three years, to give the same user the materials specified in - Subsection 6a, above, for a charge no more than the cost of - performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply, and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License -may add an explicit geographical distribution limitation excluding those -countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms -of the ordinary General Public License). - - To apply these terms, attach the following notices to the library. -It is safest to attach them to the start of each source file to most -effectively convey the exclusion of warranty; and each file should -have at least the "copyright" line and a pointer to where the full -notice is found. - - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or -your school, if any, to sign a "copyright disclaimer" for the library, -if necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James - Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - diff --git a/external/licenses/LICENSE.logilab-common-0.59.1.txt b/external/licenses/LICENSE.logilab-common-0.59.1.txt deleted file mode 100644 index 2d2d780e60..0000000000 --- a/external/licenses/LICENSE.logilab-common-0.59.1.txt +++ /dev/null @@ -1,510 +0,0 @@ - - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations -below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it -becomes a de-facto standard. To achieve this, non-free programs must -be allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control -compilation and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at least - three years, to give the same user the materials specified in - Subsection 6a, above, for a charge no more than the cost of - performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply, and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License -may add an explicit geographical distribution limitation excluding those -countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms -of the ordinary General Public License). - - To apply these terms, attach the following notices to the library. -It is safest to attach them to the start of each source file to most -effectively convey the exclusion of warranty; and each file should -have at least the "copyright" line and a pointer to where the full -notice is found. - - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or -your school, if any, to sign a "copyright disclaimer" for the library, -if necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James - Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - From d440e441051ee361865d1bc921830dae21a1b644 Mon Sep 17 00:00:00 2001 From: Matthew Taylor Date: Wed, 8 Apr 2015 11:29:35 -0700 Subject: [PATCH 079/100] Added file defining all thir-party deps. Contains name of each dependency and its license. --- DEPENDENCIES.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 DEPENDENCIES.md diff --git a/DEPENDENCIES.md b/DEPENDENCIES.md new file mode 100644 index 0000000000..1757ad1642 --- /dev/null +++ b/DEPENDENCIES.md @@ -0,0 +1,15 @@ +# Dependencies + +This file declares all dependencies nupic.core has on third-party code, including their licenses. + +- Capn Proto ([MIT License](https://github.com/sandstorm-io/capnproto/blob/master/LICENSE)) +- Boost ([Boost Software License](https://github.com/numenta/nupic.core/blob/master/external/licenses/LICENSE.boost_1_52_0.txt)) +- googletest ([googletest License](https://github.com/numenta/nupic.core/blob/master/external/licenses/LICENSE.googletest-1.7.0.txt)) +- yaml-cpp ([yaml-cpp License](https://github.com/jbeder/yaml-cpp/blob/master/LICENSE)) +- cycle_counter ([License](https://github.com/numenta/nupic.core/blob/master/external/common/include/cycle_counter.hpp)) +- zlib ([License](https://github.com/numenta/nupic.core/blob/master/external/licenses/LICENSE.zlib-1.2.3.txt)) +- apr ([License](https://github.com/numenta/nupic.core/blob/master/external/licenses/LICENSE.apr-1.2.2.txt)) +- apr-util ([License](https://github.com/numenta/nupic.core/blob/master/external/licenses/LICENSE.apr-util-1.2.2.txt)) +- freetype ([License](https://github.com/numenta/nupic.core/blob/master/external/licenses/LICENSE.freetype-2.3.4.txt)) +- libsvm ([License](https://github.com/numenta/nupic.core/blob/master/external/licenses/LICENSE.libsvm-2.84.txt)) +- opencv ([License](https://github.com/numenta/nupic.core/blob/master/external/licenses/LICENSE.opencv-1.0.0.txt)) From 31359a014a99859be1e85f218dec312166d50397 Mon Sep 17 00:00:00 2001 From: Matthew Taylor Date: Thu, 9 Apr 2015 10:36:16 -0700 Subject: [PATCH 080/100] Tweaks to AppVeyor deploy settings. --- appveyor.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index a0e35f2e25..26b9c249da 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -111,6 +111,8 @@ test: off after_build: - cd %REPO_DIR%\build\release - set PROJECT_BUILD_ARTIFACTS_DIR=%REPO_DIR%\build\artifacts + # debug: remove this line + - dir %PROJECT_BUILD_ARTIFACTS_DIR$ - ps: >- if($env:DEPLOY_TO_NUGET -eq 1) { @@ -134,17 +136,16 @@ artifacts: - path: '**\*.tar.gz' # find all Gz(ip) packages recursively deploy: - # Amazon S3 deployment provider settings - provider: S3 access_key_id: secure: AKIAIGHYSEHV3WFKOWNQ secret_access_key: - secure: YhyY/6r2LNya8OZEmVOj+fv0lY5bBPqvy8MnsdLlptXa2uqwvezkCMNKiQ+wA+tOu+BS7VRRp86DhUqCpTZ3jUM2Mwdhud/Smq7D2X8vtZBiTVcOKfQcaypDE6Zu9Zp0SjMOSf6yiq6Ruu7D5QtZ4rtaq+5uPlvbgUXRZoZm0Po= + secure: qBtFVXdym4SmRUkpLSe7ISd2txresJXSdhQnlqFN/uOdzxrRTeL8FKUD1vgQDa1S9jhiyHXMVFiA65Q7JpSvNA== bucket: "artifacts.numenta.org" - region: us-west-2 - local-dir: "%PROJECT_BUILD_ARTIFACTS_DIR%" - upload-dir: "numenta/nupic.core" - skip_cleanup: true + # region: us-west-2 + set_public: true + artifact: "%PROJECT_BUILD_ARTIFACTS_DIR%" + folder: "numenta/nupic.core/windows" on: branch: master \ No newline at end of file From 84fc9003e21b4dd78c653369ba66b4f949dc1d0f Mon Sep 17 00:00:00 2001 From: Scott Purdy Date: Thu, 9 Apr 2015 10:48:59 -0700 Subject: [PATCH 081/100] Add comparison operators to BitHistory. --- src/nupic/algorithms/BitHistory.cpp | 31 +++++++++++++++++++++++++++++ src/nupic/algorithms/BitHistory.hpp | 16 +++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/src/nupic/algorithms/BitHistory.cpp b/src/nupic/algorithms/BitHistory.cpp index b5ba15e70d..3274e0a40e 100644 --- a/src/nupic/algorithms/BitHistory.cpp +++ b/src/nupic/algorithms/BitHistory.cpp @@ -173,6 +173,37 @@ namespace nupic NTA_CHECK(marker == "~BitHistory"); } + bool BitHistory::operator==(const BitHistory& other) const + { + if (this->id_ != other.id_ || + this->lastTotalUpdate_ != other.lastTotalUpdate_ || + this->learnIteration_ != other.learnIteration_ || + this->alpha_ != other.alpha_ || + this->verbosity_ != other.verbosity_) + { + return false; + } + + if (this->stats_.size() != other.stats_.size()) + { + return false; + } + for (auto it = this->stats_.begin(); it != this->stats_.end(); it++) + { + if (it->second != other.stats_.at(it->first)) + { + return false; + } + } + + return true; + } + + bool BitHistory::operator!=(const BitHistory& other) const + { + return !operator==(other); + } + } // end namespace cla_classifier } // end namespace algorithms } // end namespace nupic diff --git a/src/nupic/algorithms/BitHistory.hpp b/src/nupic/algorithms/BitHistory.hpp index 9cd5ef63a0..b79131756c 100644 --- a/src/nupic/algorithms/BitHistory.hpp +++ b/src/nupic/algorithms/BitHistory.hpp @@ -104,6 +104,22 @@ namespace nupic */ void load(istream& inStream); + /** + * Check if the other instance matches this one. + * + * @param other an instance to compare to + * @returns true iff the other instance matches this one + */ + bool operator==(const BitHistory& other) const; + + /** + * Check if the other instance doesn't match this one. + * + * @param other an instance to compare to + * @returns true iff the other instance matches doesn't match this one + */ + bool operator!=(const BitHistory& other) const; + private: string id_; From 11bb4ac300416a7b7920f26839d1d29e156332fa Mon Sep 17 00:00:00 2001 From: Scott Purdy Date: Thu, 9 Apr 2015 10:51:33 -0700 Subject: [PATCH 082/100] Adds comparison operator to ClassifierResult. --- src/nupic/algorithms/ClassifierResult.cpp | 21 +++++++++++++++++++++ src/nupic/algorithms/ClassifierResult.hpp | 8 ++++++++ 2 files changed, 29 insertions(+) diff --git a/src/nupic/algorithms/ClassifierResult.cpp b/src/nupic/algorithms/ClassifierResult.cpp index d4e0568c5f..c2588842a4 100644 --- a/src/nupic/algorithms/ClassifierResult.cpp +++ b/src/nupic/algorithms/ClassifierResult.cpp @@ -59,6 +59,27 @@ namespace nupic return v; } + bool ClassifierResult::operator==(const ClassifierResult& other) const + { + for (auto it = result_.begin(); it != result_.end(); it++) + { + auto thisVec = it->second; + auto otherVec = other.result_.at(it->first); + if (otherVec == nullptr || thisVec->size() != otherVec->size()) + { + return false; + } + for (UInt i = 0; i < thisVec->size(); i++) + { + if (thisVec->at(i) != otherVec->at(i)) + { + return false; + } + } + } + return true; + } + } // end namespace cla_classifier } // end namespace algorithms } // end namespace nupic diff --git a/src/nupic/algorithms/ClassifierResult.hpp b/src/nupic/algorithms/ClassifierResult.hpp index 2c6a6881d8..170261ba76 100644 --- a/src/nupic/algorithms/ClassifierResult.hpp +++ b/src/nupic/algorithms/ClassifierResult.hpp @@ -75,6 +75,14 @@ namespace nupic */ virtual vector* createVector(Int step, UInt size, Real64 value); + /** + * Checks if the other instance has the exact same values. + * + * @param other The other instance to compare to. + * @returns True iff the other instance has the same values. + */ + virtual bool operator==(const ClassifierResult& other) const; + /** * Iterator method begin. */ From 19b8dbac4bf0750da1adcd3e861d3db35049aaa8 Mon Sep 17 00:00:00 2001 From: Matthew Taylor Date: Thu, 9 Apr 2015 11:00:50 -0700 Subject: [PATCH 083/100] Remove dir statement on nonexistant dir. --- appveyor.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 26b9c249da..9b3f8c3d10 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -111,8 +111,6 @@ test: off after_build: - cd %REPO_DIR%\build\release - set PROJECT_BUILD_ARTIFACTS_DIR=%REPO_DIR%\build\artifacts - # debug: remove this line - - dir %PROJECT_BUILD_ARTIFACTS_DIR$ - ps: >- if($env:DEPLOY_TO_NUGET -eq 1) { From 623a98cc5e67af7d9c8e2d44cfb2f298927436e5 Mon Sep 17 00:00:00 2001 From: Scott Purdy Date: Thu, 9 Apr 2015 11:06:36 -0700 Subject: [PATCH 084/100] Adds save/load test for FastClaClassifier. Adds comparison operator. Changes some attributes so they aren't storing pointers anymore. Fixed bug in load method where previous state wasn't being cleared before loading new state. --- src/nupic/algorithms/FastClaClassifier.cpp | 183 +++++++++++++++--- src/nupic/algorithms/FastClaClassifier.hpp | 12 +- .../unit/algorithms/FastCLAClassifierTest.cpp | 35 +++- 3 files changed, 195 insertions(+), 35 deletions(-) diff --git a/src/nupic/algorithms/FastClaClassifier.cpp b/src/nupic/algorithms/FastClaClassifier.cpp index ff63fe74cd..e65e1888f0 100644 --- a/src/nupic/algorithms/FastClaClassifier.cpp +++ b/src/nupic/algorithms/FastClaClassifier.cpp @@ -1,6 +1,6 @@ /* --------------------------------------------------------------------- * Numenta Platform for Intelligent Computing (NuPIC) - * Copyright (C) 2013, Numenta, Inc. Unless you have an agreement + * Copyright (C) 2013-2015, Numenta, Inc. Unless you have an agreement * with Numenta, Inc., for a separate license for this software code, the * following terms and conditions apply: * @@ -70,18 +70,11 @@ namespace nupic FastCLAClassifier::~FastCLAClassifier() { - // Clean up patternNZHistory_. - for (deque*>::const_iterator it = - patternNZHistory_.begin(); it != patternNZHistory_.end(); ++it) - { - delete *it; - } // Clean up activeBitHistory_. - for (map*>::const_iterator it = - activeBitHistory_.begin(); it != activeBitHistory_.end(); ++it) + for (auto it = activeBitHistory_.begin(); + it != activeBitHistory_.end(); ++it) { - for (map::const_iterator it2 = - it->second->begin(); it2 != it->second->end(); ++it2) + for (auto it2 = it->second->begin(); it2 != it->second->end(); ++it2) { delete it2->second; } @@ -106,16 +99,12 @@ namespace nupic learnIteration_ = recordNum - recordNumMinusLearnIteration_; // Update the input pattern history. - auto newPatternNZ = new vector(); - for (auto & elem : patternNZ) - { - newPatternNZ->push_back(elem); - } - patternNZHistory_.push_front(newPatternNZ); + patternNZHistory_.emplace_front(patternNZ.begin(), patternNZ.end()); + iterationNumHistory_.push_front(learnIteration_); if (patternNZHistory_.size() > maxSteps_) { - delete patternNZHistory_.back(); + //delete patternNZHistory_.back(); patternNZHistory_.pop_back(); iterationNumHistory_.pop_back(); } @@ -226,8 +215,8 @@ namespace nupic // Check if there is a pattern that should be assigned to this // classification in our history. If not, skip it. bool found = false; - deque*>::const_iterator patternIteration = - patternNZHistory_.begin(); + deque>::const_iterator patternIteration = + patternNZHistory_.begin(); for (deque::const_iterator learnIteration = iterationNumHistory_.begin(); learnIteration !=iterationNumHistory_.end(); @@ -246,8 +235,8 @@ namespace nupic // Store classification info for each active bit from the pattern // that we got step time steps ago. - const vector* learnPatternNZ = *patternIteration; - for (auto & learnPatternNZ_j : *learnPatternNZ) + const vector learnPatternNZ = *patternIteration; + for (auto & learnPatternNZ_j : learnPatternNZ) { UInt bit = learnPatternNZ_j; if (activeBitHistory_.find(step) == activeBitHistory_.end()) @@ -274,7 +263,7 @@ namespace nupic stringstream s; s.flags(ios::scientific); s.precision(numeric_limits::digits10 + 1); - this->save(s); + save(s); return s.str().size(); } @@ -313,13 +302,11 @@ namespace nupic outStream << endl; // Store the input pattern history. - vector* pattern; outStream << patternNZHistory_.size() << " "; - for (auto & elem : patternNZHistory_) + for (auto & pattern : patternNZHistory_) { - pattern = elem; - outStream << pattern->size() << " "; - for (auto & pattern_j : *pattern) + outStream << pattern.size() << " "; + for (auto & pattern_j : pattern) { outStream << pattern_j << " "; } @@ -356,6 +343,26 @@ namespace nupic void FastCLAClassifier::load(istream& inStream) { + // Clean up the existing data structures before loading + steps_.clear(); + iterationNumHistory_.clear(); + patternNZHistory_.clear(); + actualValues_.clear(); + actualValuesSet_.clear(); + // Clear activeBitHistory_ + for (auto it1 = activeBitHistory_.begin(); + it1 != activeBitHistory_.end(); it1++) + { + for (auto it2 = it1->second->begin(); it2 != it1->second->end(); + it2++) + { + delete it2->second; + } + it1->second->clear(); + delete it1->second; + } + activeBitHistory_.clear(); + // Check the starting marker. string marker; inStream >> marker; @@ -393,7 +400,6 @@ namespace nupic } // Load the prediction steps. - steps_.clear(); UInt size; UInt step; inStream >> size; @@ -409,12 +415,11 @@ namespace nupic for (UInt i = 0; i < size; ++i) { inStream >> vSize; - vector* v = new vector(vSize); + patternNZHistory_.emplace_back(vSize); for (UInt j = 0; j < vSize; ++j) { - inStream >> (*v)[j]; + inStream >> patternNZHistory_[i][j]; } - patternNZHistory_.push_back(v); if (version == 0) { iterationNumHistory_.push_back( @@ -467,6 +472,120 @@ namespace nupic version_ = Version; } + bool FastCLAClassifier::operator==(const FastCLAClassifier& other) const + { + if (steps_.size() != other.steps_.size()) + { + return false; + } + for (UInt i = 0; i < steps_.size(); i++) + { + if (steps_.at(i) != other.steps_.at(i)) + { + return false; + } + } + + if (alpha_ != other.alpha_ || + actValueAlpha_ != other.actValueAlpha_ || + learnIteration_ != other.learnIteration_ || + recordNumMinusLearnIteration_ != + other.recordNumMinusLearnIteration_ || + recordNumMinusLearnIterationSet_ != + other.recordNumMinusLearnIterationSet_ || + maxSteps_ != other.maxSteps_) + { + return false; + } + + if (patternNZHistory_.size() != other.patternNZHistory_.size()) + { + return false; + } + for (UInt i = 0; i < patternNZHistory_.size(); i++) + { + if (patternNZHistory_.at(i).size() != + other.patternNZHistory_.at(i).size()) + { + return false; + } + for (UInt j = 0; j < patternNZHistory_.at(i).size(); j++) + { + if (patternNZHistory_.at(i).at(j) != + other.patternNZHistory_.at(i).at(j)) + { + return false; + } + } + } + + if (iterationNumHistory_.size() != + other.iterationNumHistory_.size()) + { + return false; + } + for (UInt i = 0; i < iterationNumHistory_.size(); i++) + { + if (iterationNumHistory_.at(i) != + other.iterationNumHistory_.at(i)) + { + return false; + } + } + + if (activeBitHistory_.size() != other.activeBitHistory_.size()) + { + return false; + } + for (auto it1 = activeBitHistory_.begin(); + it1 != activeBitHistory_.end(); it1++) + { + auto thisInnerMap = it1->second; + auto otherInnerMap = other.activeBitHistory_.at(it1->first); + if (thisInnerMap->size() != otherInnerMap->size()) + { + return false; + } + for (auto it2 = thisInnerMap->begin(); it2 != thisInnerMap->end(); + it2++) + { + auto thisBitHistory = it2->second; + auto otherBitHistory = otherInnerMap->at(it2->first); + if (*thisBitHistory != *otherBitHistory) + { + return false; + } + } + } + + if (maxBucketIdx_ != other.maxBucketIdx_) + { + return false; + } + + if (actualValues_.size() != other.actualValues_.size() || + actualValuesSet_.size() != other.actualValuesSet_.size()) + { + return false; + } + for (UInt i = 0; i < actualValues_.size(); i++) + { + if (actualValues_.at(i) != other.actualValues_.at(i) || + actualValuesSet_.at(i) != other.actualValuesSet_.at(i)) + { + return false; + } + } + + if (version_ != other.version_ || + verbosity_ != other.verbosity_) + { + return false; + } + + return true; + } + } // end namespace cla_classifier } // end namespace algorithms } // end namespace nupic diff --git a/src/nupic/algorithms/FastClaClassifier.hpp b/src/nupic/algorithms/FastClaClassifier.hpp index db02cc89e1..286a3deafa 100644 --- a/src/nupic/algorithms/FastClaClassifier.hpp +++ b/src/nupic/algorithms/FastClaClassifier.hpp @@ -1,6 +1,6 @@ /* --------------------------------------------------------------------- * Numenta Platform for Intelligent Computing (NuPIC) - * Copyright (C) 2013, Numenta, Inc. Unless you have an agreement + * Copyright (C) 2013-2015, Numenta, Inc. Unless you have an agreement * with Numenta, Inc., for a separate license for this software code, the * following terms and conditions apply: * @@ -131,6 +131,14 @@ namespace nupic */ void load(istream& inStream); + /** + * Compare the other instance to this one. + * + * @param other Another instance of FastCLAClassifier to compare to. + * @returns true iff other is identical to this instance. + */ + virtual bool operator==(const FastCLAClassifier& other) const; + private: // The list of prediction steps to learn and infer. vector steps_; @@ -149,7 +157,7 @@ namespace nupic UInt maxSteps_; // Stores the input pattern history, starting with the previous input // and containing _maxSteps total input patterns. - deque*> patternNZHistory_; + deque< vector > patternNZHistory_; deque iterationNumHistory_; // Mapping from the number of steps in the future to predict to the // input bit index to a BitHistory that contains the duty cycles for diff --git a/src/test/unit/algorithms/FastCLAClassifierTest.cpp b/src/test/unit/algorithms/FastCLAClassifierTest.cpp index 96c7322dd1..06e4c2b7a8 100644 --- a/src/test/unit/algorithms/FastCLAClassifierTest.cpp +++ b/src/test/unit/algorithms/FastCLAClassifierTest.cpp @@ -1,6 +1,6 @@ /* --------------------------------------------------------------------- * Numenta Platform for Intelligent Computing (NuPIC) - * Copyright (C) 2013, Numenta, Inc. Unless you have an agreement + * Copyright (C) 2013-2015, Numenta, Inc. Unless you have an agreement * with Numenta, Inc., for a separate license for this software code, the * following terms and conditions apply: * @@ -24,6 +24,9 @@ * Implementation of unit tests for NearestNeighbor */ +#include +#include + #include #include @@ -102,4 +105,34 @@ namespace } } + TEST(FastCLAClassifierTest, SaveLoad) + { + vector steps; + steps.push_back(1); + FastCLAClassifier c1 = FastCLAClassifier(steps, 0.1, 0.1, 0); + FastCLAClassifier c2 = FastCLAClassifier(steps, 0.1, 0.1, 0); + + // Create a vector of input bit indices + vector input1; + input1.push_back(1); + input1.push_back(5); + input1.push_back(9); + ClassifierResult result; + c1.fastCompute(0, input1, 4, 34.7, false, true, true, &result); + + { + stringstream ss; + c1.save(ss); + c2.load(ss); + } + + ASSERT_TRUE(c1 == c2); + + ClassifierResult result1, result2; + c1.fastCompute(1, input1, 4, 35.7, false, true, true, &result1); + c2.fastCompute(1, input1, 4, 35.7, false, true, true, &result2); + + ASSERT_TRUE(result1 == result2); + } + } // end namespace From 291b5bc0f484a21a12856e42442275adad3c586c Mon Sep 17 00:00:00 2001 From: Scott Purdy Date: Thu, 9 Apr 2015 11:40:53 -0700 Subject: [PATCH 085/100] Changes activeBitHistory_ to not have any attributes allocated on the heap. --- src/nupic/algorithms/FastClaClassifier.cpp | 82 +++++++--------------- src/nupic/algorithms/FastClaClassifier.hpp | 3 +- 2 files changed, 26 insertions(+), 59 deletions(-) diff --git a/src/nupic/algorithms/FastClaClassifier.cpp b/src/nupic/algorithms/FastClaClassifier.cpp index e65e1888f0..458cb507e5 100644 --- a/src/nupic/algorithms/FastClaClassifier.cpp +++ b/src/nupic/algorithms/FastClaClassifier.cpp @@ -70,16 +70,6 @@ namespace nupic FastCLAClassifier::~FastCLAClassifier() { - // Clean up activeBitHistory_. - for (auto it = activeBitHistory_.begin(); - it != activeBitHistory_.end(); ++it) - { - for (auto it2 = it->second->begin(); it2 != it->second->end(); ++it2) - { - delete it2->second; - } - delete it->second; - } } void FastCLAClassifier::fastCompute( @@ -136,8 +126,7 @@ namespace nupic } // Generate the predictions for each steps-ahead value - for (vector::const_iterator step = steps_.begin(); - step != steps_.end(); ++step) + for (auto step = steps_.begin(); step != steps_.end(); ++step) { // Skip if we don't have data yet. if (activeBitHistory_.find(*step) == activeBitHistory_.end()) @@ -154,15 +143,15 @@ namespace nupic for (const auto & elem : patternNZ) { - if (activeBitHistory_[*step]->find(elem) != - activeBitHistory_[*step]->end()) + if (activeBitHistory_[*step].find(elem) != + activeBitHistory_[*step].end()) { - BitHistory* history = - activeBitHistory_[*step]->find(elem)->second; + BitHistory& history = + activeBitHistory_[*step].find(elem)->second; for (auto & bitVote : bitVotes) { bitVote = 0.0; } - history->infer(learnIteration_, &bitVotes); + history.infer(learnIteration_, &bitVotes); for (UInt i = 0; i < bitVotes.size(); ++i) { (*likelihoods)[i] += bitVotes[i]; } @@ -239,19 +228,15 @@ namespace nupic for (auto & learnPatternNZ_j : learnPatternNZ) { UInt bit = learnPatternNZ_j; - if (activeBitHistory_.find(step) == activeBitHistory_.end()) + // This will implicitly insert the key "step" into the map if it + // doesn't exist yet. + auto it = activeBitHistory_[step].find(bit); + if (it == activeBitHistory_[step].end()) { - activeBitHistory_.insert(pair*>( - step, new map())); + activeBitHistory_[step][bit] = + BitHistory(bit, step, alpha_, verbosity_); } - map::const_iterator it = - activeBitHistory_[step]->find(bit); - if (it == activeBitHistory_[step]->end()) - { - (*activeBitHistory_[step])[bit] = - new BitHistory(bit, step, alpha_, verbosity_); - } - (*activeBitHistory_[step])[bit]->store(learnIteration_, bucketIdx); + activeBitHistory_[step][bit].store(learnIteration_, bucketIdx); } } } @@ -318,12 +303,11 @@ namespace nupic for (const auto & elem : activeBitHistory_) { outStream << elem.first << " "; - outStream << elem.second->size() << " "; - for (map::const_iterator it2 = - elem.second->begin(); it2 != elem.second->end(); ++it2) + outStream << elem.second.size() << " "; + for (auto it2 = elem.second.begin(); it2 != elem.second.end(); ++it2) { outStream << it2->first << " "; - it2->second->save(outStream); + it2->second.save(outStream); } } @@ -349,18 +333,6 @@ namespace nupic patternNZHistory_.clear(); actualValues_.clear(); actualValuesSet_.clear(); - // Clear activeBitHistory_ - for (auto it1 = activeBitHistory_.begin(); - it1 != activeBitHistory_.end(); it1++) - { - for (auto it2 = it1->second->begin(); it2 != it1->second->end(); - it2++) - { - delete it2->second; - } - it1->second->clear(); - delete it1->second; - } activeBitHistory_.clear(); // Check the starting marker. @@ -431,24 +403,18 @@ namespace nupic UInt numSteps; UInt numInputBits; UInt inputBit; - BitHistory* bitHistory; - map* bitHistoryMap; + map* bitHistoryMap; inStream >> numSteps; for (UInt i = 0; i < numSteps; ++i) { inStream >> step; + bitHistoryMap = &activeBitHistory_[step]; inStream >> numInputBits; - bitHistoryMap = new map(); for (UInt j = 0; j < numInputBits; ++j) { inStream >> inputBit; - bitHistory = new BitHistory(); - bitHistory->load(inStream); - bitHistoryMap->insert( - pair(inputBit, bitHistory)); + bitHistoryMap->at(inputBit).load(inStream); } - activeBitHistory_.insert( - pair*>(step, bitHistoryMap)); } // Load the actual values for each bucket. @@ -542,16 +508,16 @@ namespace nupic { auto thisInnerMap = it1->second; auto otherInnerMap = other.activeBitHistory_.at(it1->first); - if (thisInnerMap->size() != otherInnerMap->size()) + if (thisInnerMap.size() != otherInnerMap.size()) { return false; } - for (auto it2 = thisInnerMap->begin(); it2 != thisInnerMap->end(); - it2++) + for (auto it2 = thisInnerMap.begin(); it2 != thisInnerMap.end(); + it2++) { auto thisBitHistory = it2->second; - auto otherBitHistory = otherInnerMap->at(it2->first); - if (*thisBitHistory != *otherBitHistory) + auto otherBitHistory = otherInnerMap.at(it2->first); + if (thisBitHistory != otherBitHistory) { return false; } diff --git a/src/nupic/algorithms/FastClaClassifier.hpp b/src/nupic/algorithms/FastClaClassifier.hpp index 286a3deafa..5f0b53422d 100644 --- a/src/nupic/algorithms/FastClaClassifier.hpp +++ b/src/nupic/algorithms/FastClaClassifier.hpp @@ -33,6 +33,7 @@ #include #include +#include #include using namespace std; @@ -162,7 +163,7 @@ namespace nupic // Mapping from the number of steps in the future to predict to the // input bit index to a BitHistory that contains the duty cycles for // each bucket. - map* > activeBitHistory_; + map< UInt, map > activeBitHistory_; // The highest bucket index that has been seen so far. UInt maxBucketIdx_; // The current actual values used for each bucket index. The index of From e420e395d1e72bc51197869ecb49e4e81892499a Mon Sep 17 00:00:00 2001 From: Scott Purdy Date: Thu, 9 Apr 2015 11:51:15 -0700 Subject: [PATCH 086/100] Updates copyright header years for modified files. --- src/nupic/algorithms/BitHistory.cpp | 2 +- src/nupic/algorithms/BitHistory.hpp | 2 +- src/nupic/algorithms/ClassifierResult.cpp | 2 +- src/nupic/algorithms/ClassifierResult.hpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/nupic/algorithms/BitHistory.cpp b/src/nupic/algorithms/BitHistory.cpp index 3274e0a40e..5839c9af25 100644 --- a/src/nupic/algorithms/BitHistory.cpp +++ b/src/nupic/algorithms/BitHistory.cpp @@ -1,6 +1,6 @@ /* --------------------------------------------------------------------- * Numenta Platform for Intelligent Computing (NuPIC) - * Copyright (C) 2013, Numenta, Inc. Unless you have an agreement + * Copyright (C) 2013-2015, Numenta, Inc. Unless you have an agreement * with Numenta, Inc., for a separate license for this software code, the * following terms and conditions apply: * diff --git a/src/nupic/algorithms/BitHistory.hpp b/src/nupic/algorithms/BitHistory.hpp index b79131756c..d7542a28a5 100644 --- a/src/nupic/algorithms/BitHistory.hpp +++ b/src/nupic/algorithms/BitHistory.hpp @@ -1,6 +1,6 @@ /* --------------------------------------------------------------------- * Numenta Platform for Intelligent Computing (NuPIC) - * Copyright (C) 2013, Numenta, Inc. Unless you have an agreement + * Copyright (C) 2013-2015, Numenta, Inc. Unless you have an agreement * with Numenta, Inc., for a separate license for this software code, the * following terms and conditions apply: * diff --git a/src/nupic/algorithms/ClassifierResult.cpp b/src/nupic/algorithms/ClassifierResult.cpp index c2588842a4..86beb6a3e2 100644 --- a/src/nupic/algorithms/ClassifierResult.cpp +++ b/src/nupic/algorithms/ClassifierResult.cpp @@ -1,6 +1,6 @@ /* --------------------------------------------------------------------- * Numenta Platform for Intelligent Computing (NuPIC) - * Copyright (C) 2013, Numenta, Inc. Unless you have an agreement + * Copyright (C) 2013-2015, Numenta, Inc. Unless you have an agreement * with Numenta, Inc., for a separate license for this software code, the * following terms and conditions apply: * diff --git a/src/nupic/algorithms/ClassifierResult.hpp b/src/nupic/algorithms/ClassifierResult.hpp index 170261ba76..62bcebccae 100644 --- a/src/nupic/algorithms/ClassifierResult.hpp +++ b/src/nupic/algorithms/ClassifierResult.hpp @@ -1,6 +1,6 @@ /* --------------------------------------------------------------------- * Numenta Platform for Intelligent Computing (NuPIC) - * Copyright (C) 2013, Numenta, Inc. Unless you have an agreement + * Copyright (C) 2013-2015, Numenta, Inc. Unless you have an agreement * with Numenta, Inc., for a separate license for this software code, the * following terms and conditions apply: * From bca2761c35f5b88fb1ffb7cd1e586678e325a14e Mon Sep 17 00:00:00 2001 From: Scott Purdy Date: Thu, 9 Apr 2015 13:51:59 -0700 Subject: [PATCH 087/100] Code review clean up of commented out code. --- src/nupic/algorithms/FastClaClassifier.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/nupic/algorithms/FastClaClassifier.cpp b/src/nupic/algorithms/FastClaClassifier.cpp index 458cb507e5..0a6e9ea46d 100644 --- a/src/nupic/algorithms/FastClaClassifier.cpp +++ b/src/nupic/algorithms/FastClaClassifier.cpp @@ -94,7 +94,6 @@ namespace nupic iterationNumHistory_.push_front(learnIteration_); if (patternNZHistory_.size() > maxSteps_) { - //delete patternNZHistory_.back(); patternNZHistory_.pop_back(); iterationNumHistory_.pop_back(); } From 0b9bd57b265767cfffbab628fe2d110de2d70306 Mon Sep 17 00:00:00 2001 From: Matthew Taylor Date: Thu, 9 Apr 2015 14:12:55 -0700 Subject: [PATCH 088/100] Tweaking S3 deployment settings. - adding region - changing destination folder --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 9b3f8c3d10..d1e60e3df6 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -141,9 +141,9 @@ deploy: secret_access_key: secure: qBtFVXdym4SmRUkpLSe7ISd2txresJXSdhQnlqFN/uOdzxrRTeL8FKUD1vgQDa1S9jhiyHXMVFiA65Q7JpSvNA== bucket: "artifacts.numenta.org" - # region: us-west-2 + region: us-west-2 set_public: true artifact: "%PROJECT_BUILD_ARTIFACTS_DIR%" - folder: "numenta/nupic.core/windows" + folder: "numenta/nupic.core" on: branch: master \ No newline at end of file From e63d7a50a4a2e6613769ab01adb9c0c16d21ac58 Mon Sep 17 00:00:00 2001 From: Matthew Taylor Date: Thu, 9 Apr 2015 16:20:11 -0700 Subject: [PATCH 089/100] S3 deployment attempt with proper artifact name. --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index d1e60e3df6..9862fbc2b8 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -143,7 +143,7 @@ deploy: bucket: "artifacts.numenta.org" region: us-west-2 set_public: true - artifact: "%PROJECT_BUILD_ARTIFACTS_DIR%" + artifact: "nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz" folder: "numenta/nupic.core" on: branch: master \ No newline at end of file From a34c0af5f8b883a8dcfd0de90b3c554101cf269f Mon Sep 17 00:00:00 2001 From: Scott Purdy Date: Thu, 9 Apr 2015 16:24:50 -0700 Subject: [PATCH 090/100] Fix bug in loading classifier --- src/nupic/algorithms/FastClaClassifier.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/nupic/algorithms/FastClaClassifier.cpp b/src/nupic/algorithms/FastClaClassifier.cpp index 0a6e9ea46d..9d200205e1 100644 --- a/src/nupic/algorithms/FastClaClassifier.cpp +++ b/src/nupic/algorithms/FastClaClassifier.cpp @@ -402,17 +402,17 @@ namespace nupic UInt numSteps; UInt numInputBits; UInt inputBit; - map* bitHistoryMap; inStream >> numSteps; for (UInt i = 0; i < numSteps; ++i) { inStream >> step; - bitHistoryMap = &activeBitHistory_[step]; + // Insert the step to initialize the BitHistory + activeBitHistory_[step]; inStream >> numInputBits; for (UInt j = 0; j < numInputBits; ++j) { inStream >> inputBit; - bitHistoryMap->at(inputBit).load(inStream); + activeBitHistory_[step][inputBit].load(inStream); } } From 9bb45a924d9d784ee55ce78fdd45599578cb8dc7 Mon Sep 17 00:00:00 2001 From: Matthew Taylor Date: Fri, 10 Apr 2015 08:34:18 -0700 Subject: [PATCH 091/100] AppVeyor S3 deploy tweak (proper repo commit injection) --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 9862fbc2b8..510a4fdecf 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -143,7 +143,7 @@ deploy: bucket: "artifacts.numenta.org" region: us-west-2 set_public: true - artifact: "nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz" + artifact: "nupic_core-$(APPVEYOR_REPO_COMMIT)-Windows64.tar.gz" folder: "numenta/nupic.core" on: branch: master \ No newline at end of file From d84cd7b66b5ae3d64253bbe7ed5c6a56da788c92 Mon Sep 17 00:00:00 2001 From: Matthew Taylor Date: Fri, 10 Apr 2015 09:18:28 -0700 Subject: [PATCH 092/100] Updating AWS encrypted keys. --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 510a4fdecf..01092b5d48 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -137,9 +137,9 @@ deploy: # Amazon S3 deployment provider settings - provider: S3 access_key_id: - secure: AKIAIGHYSEHV3WFKOWNQ + secure: /9U0mCHp3k1U8Y5CY/kDqwCKG2gqchG/T/UlVWo8SME= secret_access_key: - secure: qBtFVXdym4SmRUkpLSe7ISd2txresJXSdhQnlqFN/uOdzxrRTeL8FKUD1vgQDa1S9jhiyHXMVFiA65Q7JpSvNA== + secure: /8wO17Gir0XAiecJkHeE3jxOJzvyl0+uWcl7BKCuN0FC795golsL8905VmNuRl1o bucket: "artifacts.numenta.org" region: us-west-2 set_public: true From 029611a19b415b35262b163081f9af3992d926be Mon Sep 17 00:00:00 2001 From: Scott Purdy Date: Mon, 6 Apr 2015 11:25:37 -0700 Subject: [PATCH 093/100] good way along with classifier capn proto implementation --- src/CMakeLists.txt | 2 + src/nupic/algorithms/BitHistory.cpp | 36 +++++ src/nupic/algorithms/BitHistory.hpp | 11 ++ src/nupic/algorithms/FastClaClassifier.cpp | 163 +++++++++++++++++++++ src/nupic/algorithms/FastClaClassifier.hpp | 11 ++ src/nupic/proto/BitHistory.capnp | 18 +++ src/nupic/proto/CLAClassifier.capnp | 35 +++++ 7 files changed, 276 insertions(+) create mode 100644 src/nupic/proto/BitHistory.capnp create mode 100644 src/nupic/proto/CLAClassifier.capnp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 435e5f4d40..2b99a3d156 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -307,6 +307,8 @@ include_directories(${CAPNP_INCLUDE_DIRS}) # List all .capnp files here. The C++ files will be generated and included # when compiling later on. set(CAPNP_SPECS + nupic/proto/BitHistory.capnp + nupic/proto/CLAClassifier.capnp nupic/proto/RandomProto.capnp nupic/proto/SparseBinaryMatrixProto.capnp nupic/proto/SparseMatrixProto.capnp diff --git a/src/nupic/algorithms/BitHistory.cpp b/src/nupic/algorithms/BitHistory.cpp index 5839c9af25..64fb1beea9 100644 --- a/src/nupic/algorithms/BitHistory.cpp +++ b/src/nupic/algorithms/BitHistory.cpp @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -172,6 +173,41 @@ namespace nupic inStream >> marker; NTA_CHECK(marker == "~BitHistory"); } + void BitHistory::write(BitHistoryProto::Builder& proto) const + { + proto.setId(id_); + + auto statsList = proto.initStats(stats_.size()); + UInt i = 0; + for (const auto & elem : stats_) + { + auto stat = statsList[i]; + stat.setIndex(elem.first); + stat.setDutyCycle(elem.second); + i++; + } + + proto.setLastTotalUpdate(lastTotalUpdate_); + proto.setLearnIteration(learnIteration_); + proto.setAlpha(alpha_); + proto.setVerbosity(verbosity_); + } + + void BitHistory::read(BitHistoryProto::Reader& proto) + { + id_ = proto.getId(); + + stats_.clear(); + for (auto stat : proto.getStats()) + { + stats_[stat.getIndex()] = stat.getDutyCycle(); + } + + lastTotalUpdate_ = proto.getLastTotalUpdate(); + learnIteration_ = proto.getLearnIteration(); + alpha_ = proto.getAlpha(); + verbosity_ = proto.getVerbosity(); + } bool BitHistory::operator==(const BitHistory& other) const { diff --git a/src/nupic/algorithms/BitHistory.hpp b/src/nupic/algorithms/BitHistory.hpp index d7542a28a5..aa725b8278 100644 --- a/src/nupic/algorithms/BitHistory.hpp +++ b/src/nupic/algorithms/BitHistory.hpp @@ -31,6 +31,7 @@ #include #include +#include #include using namespace std; @@ -104,6 +105,16 @@ namespace nupic */ void load(istream& inStream); + /** + * Save the state to the builder. + */ + void write(BitHistoryProto::Builder& builder) const; + + /** + * Load state from reader. + */ + void read(BitHistoryProto::Reader& proto); + /** * Check if the other instance matches this one. * diff --git a/src/nupic/algorithms/FastClaClassifier.cpp b/src/nupic/algorithms/FastClaClassifier.cpp index 9d200205e1..a173d1dd96 100644 --- a/src/nupic/algorithms/FastClaClassifier.cpp +++ b/src/nupic/algorithms/FastClaClassifier.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -437,6 +438,168 @@ namespace nupic version_ = Version; } + void FastCLAClassifier::write(ClaClassifierProto::Builder& proto) const + { + auto stepsProto = proto.initSteps(steps_.size()); + for (UInt i = 0; i < steps_.size(); i++) + { + stepsProto.set(i, steps_[i]); + } + + proto.setAlpha(alpha_); + proto.setActValueAlpha(actValueAlpha_); + proto.setLearnIteration(learnIteration_); + proto.setRecordNumMinusLearnIteration(recordNumMinusLearnIteration_); + proto.setRecordNumMinusLearnIterationSet( + recordNumMinusLearnIterationSet_); + proto.setMaxSteps(maxSteps_); + + auto patternNZHistoryProto = + proto.initPatternNZHistory(patternNZHistory_.size()); + for (UInt i = 0; i < patternNZHistory_.size(); i++) + { + const auto & pattern = *patternNZHistory_[i]; + auto patternProto = patternNZHistoryProto.init(i, pattern.size()); + for (UInt j = 0; j < pattern.size(); j++) + { + patternProto.set(j, pattern[j]); + } + } + + auto iterationNumHistoryProto = + proto.initIterationNumHistory(iterationNumHistory_.size()); + for (UInt i = 0; i < iterationNumHistory_.size(); i++) + { + iterationNumHistoryProto.set(i, iterationNumHistory_[i]); + } + + auto activeBitHistoryProtos = + proto.initActiveBitHistory(activeBitHistory_.size()); + UInt i = 0; + for (const auto & stepBitHistory : activeBitHistory_) + { + auto stepBitHistoryProto = activeBitHistoryProtos[i]; + stepBitHistoryProto.setSteps(stepBitHistory.first); + auto indexBitHistoryListProto = + stepBitHistoryProto.initBitHistories(stepBitHistory.second->size()); + UInt j = 0; + for (const auto & indexBitHistory : *stepBitHistory.second) + { + auto indexBitHistoryProto = indexBitHistoryListProto[j]; + indexBitHistoryProto.setIndex(indexBitHistory.first); + auto bitHistoryProto = indexBitHistoryProto.initHistory(); + indexBitHistory.second->write(bitHistoryProto); + j++; + } + i++; + } + + proto.setMaxBucketIdx(maxBucketIdx_); + + auto actualValuesProto = proto.initActualValues(actualValues_.size()); + for (UInt i = 0; i < actualValues_.size(); i++) + { + actualValuesProto.set(i, actualValues_[i]); + } + + auto actualValuesSetProto = + proto.initActualValuesSet(actualValuesSet_.size()); + for (UInt i = 0; i < actualValuesSet_.size(); i++) + { + actualValuesSetProto.set(i, actualValuesSet_[i]); + } + + proto.setVersion(version_); + proto.setVerbosity(verbosity_); + } + + void FastCLAClassifier::read(ClaClassifierProto::Reader& proto) + { + // Clear previous steps + steps_.clear(); + for (auto step : proto.getSteps()) + { + steps_.push_back(step); + } + + alpha_ = proto.getAlpha(); + actValueAlpha_ = proto.getActValueAlpha(); + learnIteration_ = proto.getLearnIteration(); + recordNumMinusLearnIteration_ = proto.getRecordNumMinusLearnIteration(); + recordNumMinusLearnIterationSet_ = + proto.getRecordNumMinusLearnIterationSet(); + maxSteps_ = proto.getMaxSteps(); + + // Clear old history + for (auto innerVector : patternNZHistory_) + { + delete innerVector; + } + patternNZHistory_.clear(); + auto patternNZHistoryProto = proto.getPatternNZHistory(); + for (UInt i = 0; i < patternNZHistoryProto.size(); i++) + { + vector* history = + new vector(patternNZHistoryProto[i].size()); + for (UInt j = 0; j < patternNZHistoryProto[i].size(); j++) + { + (*history)[j] = patternNZHistoryProto[i][j]; + } + patternNZHistory_.push_back(history); + } + + iterationNumHistory_.clear(); + auto iterationNumHistoryProto = proto.getIterationNumHistory(); + for (UInt i = 0; i < iterationNumHistoryProto.size(); i++) + { + iterationNumHistory_.push_back(iterationNumHistoryProto[i]); + } + + auto activeBitHistoryProto = proto.getActiveBitHistory(); + for (UInt i = 0; i < activeBitHistoryProto.size(); i++) + { + d + } + // auto activeBitHistoryProtos = + // proto.initActiveBitHistory(activeBitHistory_.size()); + // UInt i = 0; + // for (const auto & stepBitHistory : activeBitHistory_) + // { + // auto stepBitHistoryProto = activeBitHistoryProtos[i]; + // stepBitHistoryProto.setSteps(stepBitHistory.first); + // auto indexBitHistoryListProto = + // stepBitHistoryProto.initBitHistories(stepBitHistory.second->size()); + // UInt j = 0; + // for (const auto & indexBitHistory : *stepBitHistory.second) + // { + // auto indexBitHistoryProto = indexBitHistoryListProto[j]; + // indexBitHistoryProto.setIndex(indexBitHistory.first); + // auto bitHistoryProto = indexBitHistoryProto.initHistory(); + // indexBitHistory.second->write(bitHistoryProto); + // j++; + // } + // i++; + // } + + // proto.setMaxBucketIdx(maxBucketIdx_); + + // auto actualValuesProto = proto.initActualValues(actualValues_.size()); + // for (UInt i = 0; i < actualValues_.size(); i++) + // { + // actualValuesProto.set(i, actualValues_[i]); + // } + + // auto actualValuesSetProto = + // proto.initActualValuesSet(actualValuesSet_.size()); + // for (UInt i = 0; i < actualValuesSet_.size(); i++) + // { + // actualValuesSetProto.set(i, actualValuesSet_[i]); + // } + + // proto.setVersion(version_); + // proto.setVerbosity(verbosity_); + } + bool FastCLAClassifier::operator==(const FastCLAClassifier& other) const { if (steps_.size() != other.steps_.size()) diff --git a/src/nupic/algorithms/FastClaClassifier.hpp b/src/nupic/algorithms/FastClaClassifier.hpp index 5f0b53422d..85054e9bde 100644 --- a/src/nupic/algorithms/FastClaClassifier.hpp +++ b/src/nupic/algorithms/FastClaClassifier.hpp @@ -34,6 +34,7 @@ #include #include +#include #include using namespace std; @@ -132,6 +133,16 @@ namespace nupic */ void load(istream& inStream); + /** + * Save the state to the builder. + */ + void write(ClaClassifierProto::Builder& proto) const; + + /** + * Load state from reader. + */ + void read(ClaClassifierProto::Reader& proto); + /** * Compare the other instance to this one. * diff --git a/src/nupic/proto/BitHistory.capnp b/src/nupic/proto/BitHistory.capnp new file mode 100644 index 0000000000..dcb22def9e --- /dev/null +++ b/src/nupic/proto/BitHistory.capnp @@ -0,0 +1,18 @@ +@0xc7158cb7b34ac59a; + +# Next ID: 6 +struct BitHistoryProto { + # This is currently unused and should probably be removed. + id @0 :Text; + stats @1 :List(Stat); + lastTotalUpdate @2 :UInt32; + learnIteration @3 :UInt32; + alpha @4 :Float32; + verbosity @5 :UInt8; + + # Next ID: 2 + struct Stat { + index @0 :UInt32; # Check if actually unsigned + dutyCycle @1 :Float32; + } +} diff --git a/src/nupic/proto/CLAClassifier.capnp b/src/nupic/proto/CLAClassifier.capnp new file mode 100644 index 0000000000..25ffcb5c31 --- /dev/null +++ b/src/nupic/proto/CLAClassifier.capnp @@ -0,0 +1,35 @@ +@0xc8e1bdd87a2feed9; + +using import "BitHistory.capnp".BitHistoryProto; + +# Next ID: 15 +struct ClaClassifierProto { + steps @0 :List(UInt16); + alpha @1 :Float32; + actValueAlpha @2 :Float32; + learnIteration @3 :UInt32; + recordNumMinusLearnIteration @4 :UInt32; + recordNumMinusLearnIterationSet @5 :Bool; + maxSteps @6 :UInt32; + patternNZHistory @7 :List(List(UInt32)); + iterationNumHistory @8 :List(UInt32); + activeBitHistory @9 :List(StepBitHistories); + maxBucketIdx @10 :UInt32; + actualValues @11 :List(Float32); + # Each index is true if the corresponding index in actualValues has been set. + actualValuesSet @12 :List(Bool); + version @13 :UInt16; + verbosity @14 :UInt8; + + # Next ID: 2 + struct StepBitHistories { + steps @0 :UInt32; + bitHistories @1 :List(IndexBitHistory); + + # Next ID: 2 + struct IndexBitHistory { + index @0 :UInt32; + history @1 :BitHistoryProto; + } + } +} From 30ff326980c0eef47991a1ea0b1b0b215945e82c Mon Sep 17 00:00:00 2001 From: Scott Purdy Date: Fri, 10 Apr 2015 11:07:13 -0700 Subject: [PATCH 094/100] Adds Cap'n Proto serialization to the cla classifier along with a basic test case. --- src/nupic/algorithms/BitHistory.cpp | 17 +-- src/nupic/algorithms/ClassifierResult.cpp | 3 +- src/nupic/algorithms/FastClaClassifier.cpp | 126 +++++++++--------- src/nupic/algorithms/FastClaClassifier.hpp | 10 ++ .../unit/algorithms/FastCLAClassifierTest.cpp | 30 +++++ 5 files changed, 117 insertions(+), 69 deletions(-) diff --git a/src/nupic/algorithms/BitHistory.cpp b/src/nupic/algorithms/BitHistory.cpp index 64fb1beea9..7f6af2cb53 100644 --- a/src/nupic/algorithms/BitHistory.cpp +++ b/src/nupic/algorithms/BitHistory.cpp @@ -20,6 +20,7 @@ * --------------------------------------------------------------------- */ +#include #include #include #include @@ -211,22 +212,22 @@ namespace nupic bool BitHistory::operator==(const BitHistory& other) const { - if (this->id_ != other.id_ || - this->lastTotalUpdate_ != other.lastTotalUpdate_ || - this->learnIteration_ != other.learnIteration_ || - this->alpha_ != other.alpha_ || - this->verbosity_ != other.verbosity_) + if (id_ != other.id_ || + lastTotalUpdate_ != other.lastTotalUpdate_ || + learnIteration_ != other.learnIteration_ || + fabs(alpha_ - other.alpha_) > 0.000001 || + verbosity_ != other.verbosity_) { return false; } - if (this->stats_.size() != other.stats_.size()) + if (stats_.size() != other.stats_.size()) { return false; } - for (auto it = this->stats_.begin(); it != this->stats_.end(); it++) + for (auto it = stats_.begin(); it != stats_.end(); it++) { - if (it->second != other.stats_.at(it->first)) + if (fabs(it->second - other.stats_.at(it->first)) > 0.000001) { return false; } diff --git a/src/nupic/algorithms/ClassifierResult.cpp b/src/nupic/algorithms/ClassifierResult.cpp index 86beb6a3e2..bbbe00db40 100644 --- a/src/nupic/algorithms/ClassifierResult.cpp +++ b/src/nupic/algorithms/ClassifierResult.cpp @@ -20,6 +20,7 @@ * --------------------------------------------------------------------- */ +#include #include #include @@ -71,7 +72,7 @@ namespace nupic } for (UInt i = 0; i < thisVec->size(); i++) { - if (thisVec->at(i) != otherVec->at(i)) + if (fabs(thisVec->at(i) - otherVec->at(i)) > 0.000001) { return false; } diff --git a/src/nupic/algorithms/FastClaClassifier.cpp b/src/nupic/algorithms/FastClaClassifier.cpp index a173d1dd96..d4cbab5705 100644 --- a/src/nupic/algorithms/FastClaClassifier.cpp +++ b/src/nupic/algorithms/FastClaClassifier.cpp @@ -20,6 +20,7 @@ * --------------------------------------------------------------------- */ +#include #include #include #include @@ -29,6 +30,10 @@ #include #include +#include +#include +#include + #include #include #include @@ -458,7 +463,7 @@ namespace nupic proto.initPatternNZHistory(patternNZHistory_.size()); for (UInt i = 0; i < patternNZHistory_.size(); i++) { - const auto & pattern = *patternNZHistory_[i]; + const auto & pattern = patternNZHistory_[i]; auto patternProto = patternNZHistoryProto.init(i, pattern.size()); for (UInt j = 0; j < pattern.size(); j++) { @@ -481,14 +486,14 @@ namespace nupic auto stepBitHistoryProto = activeBitHistoryProtos[i]; stepBitHistoryProto.setSteps(stepBitHistory.first); auto indexBitHistoryListProto = - stepBitHistoryProto.initBitHistories(stepBitHistory.second->size()); + stepBitHistoryProto.initBitHistories(stepBitHistory.second.size()); UInt j = 0; - for (const auto & indexBitHistory : *stepBitHistory.second) + for (const auto & indexBitHistory : stepBitHistory.second) { auto indexBitHistoryProto = indexBitHistoryListProto[j]; indexBitHistoryProto.setIndex(indexBitHistory.first); auto bitHistoryProto = indexBitHistoryProto.initHistory(); - indexBitHistory.second->write(bitHistoryProto); + indexBitHistory.second.write(bitHistoryProto); j++; } i++; @@ -513,10 +518,26 @@ namespace nupic proto.setVerbosity(verbosity_); } + void FastCLAClassifier::write(ostream& stream) const + { + capnp::MallocMessageBuilder message; + auto proto = message.initRoot(); + write(proto); + + kj::std::StdOutputStream out(stream); + capnp::writeMessage(out, message); + } + void FastCLAClassifier::read(ClaClassifierProto::Reader& proto) { - // Clear previous steps + // Clean up the existing data structures before loading steps_.clear(); + iterationNumHistory_.clear(); + patternNZHistory_.clear(); + actualValues_.clear(); + actualValuesSet_.clear(); + activeBitHistory_.clear(); + for (auto step : proto.getSteps()) { steps_.push_back(step); @@ -530,25 +551,16 @@ namespace nupic proto.getRecordNumMinusLearnIterationSet(); maxSteps_ = proto.getMaxSteps(); - // Clear old history - for (auto innerVector : patternNZHistory_) - { - delete innerVector; - } - patternNZHistory_.clear(); auto patternNZHistoryProto = proto.getPatternNZHistory(); for (UInt i = 0; i < patternNZHistoryProto.size(); i++) { - vector* history = - new vector(patternNZHistoryProto[i].size()); + patternNZHistory_.emplace_back(patternNZHistoryProto[i].size()); for (UInt j = 0; j < patternNZHistoryProto[i].size(); j++) { - (*history)[j] = patternNZHistoryProto[i][j]; + patternNZHistory_[i][j] = patternNZHistoryProto[i][j]; } - patternNZHistory_.push_back(history); } - iterationNumHistory_.clear(); auto iterationNumHistoryProto = proto.getIterationNumHistory(); for (UInt i = 0; i < iterationNumHistoryProto.size(); i++) { @@ -558,46 +570,40 @@ namespace nupic auto activeBitHistoryProto = proto.getActiveBitHistory(); for (UInt i = 0; i < activeBitHistoryProto.size(); i++) { - d - } - // auto activeBitHistoryProtos = - // proto.initActiveBitHistory(activeBitHistory_.size()); - // UInt i = 0; - // for (const auto & stepBitHistory : activeBitHistory_) - // { - // auto stepBitHistoryProto = activeBitHistoryProtos[i]; - // stepBitHistoryProto.setSteps(stepBitHistory.first); - // auto indexBitHistoryListProto = - // stepBitHistoryProto.initBitHistories(stepBitHistory.second->size()); - // UInt j = 0; - // for (const auto & indexBitHistory : *stepBitHistory.second) - // { - // auto indexBitHistoryProto = indexBitHistoryListProto[j]; - // indexBitHistoryProto.setIndex(indexBitHistory.first); - // auto bitHistoryProto = indexBitHistoryProto.initHistory(); - // indexBitHistory.second->write(bitHistoryProto); - // j++; - // } - // i++; - // } - - // proto.setMaxBucketIdx(maxBucketIdx_); - - // auto actualValuesProto = proto.initActualValues(actualValues_.size()); - // for (UInt i = 0; i < actualValues_.size(); i++) - // { - // actualValuesProto.set(i, actualValues_[i]); - // } - - // auto actualValuesSetProto = - // proto.initActualValuesSet(actualValuesSet_.size()); - // for (UInt i = 0; i < actualValuesSet_.size(); i++) - // { - // actualValuesSetProto.set(i, actualValuesSet_[i]); - // } - - // proto.setVersion(version_); - // proto.setVerbosity(verbosity_); + auto stepBitHistories = activeBitHistoryProto[i]; + UInt steps = stepBitHistories.getSteps(); + for (auto indexBitHistoryProto : stepBitHistories.getBitHistories()) + { + BitHistory& bitHistory = + activeBitHistory_[steps][indexBitHistoryProto.getIndex()]; + auto bitHistoryProto = indexBitHistoryProto.getHistory(); + bitHistory.read(bitHistoryProto); + } + } + + maxBucketIdx_ = proto.getMaxBucketIdx(); + + for (auto actValue : proto.getActualValues()) + { + actualValues_.push_back(actValue); + } + + for (auto actValueSet : proto.getActualValuesSet()) + { + actualValuesSet_.push_back(actValueSet); + } + + version_ = proto.getVersion(); + verbosity_ = proto.getVerbosity(); + } + + void FastCLAClassifier::read(istream& stream) + { + kj::std::StdInputStream in(stream); + + capnp::InputStreamMessageReader message(in); + auto proto = message.getRoot(); + read(proto); } bool FastCLAClassifier::operator==(const FastCLAClassifier& other) const @@ -614,8 +620,8 @@ namespace nupic } } - if (alpha_ != other.alpha_ || - actValueAlpha_ != other.actValueAlpha_ || + if (fabs(alpha_ - other.alpha_) > 0.000001 || + fabs(actValueAlpha_ - other.actValueAlpha_) > 0.000001 || learnIteration_ != other.learnIteration_ || recordNumMinusLearnIteration_ != other.recordNumMinusLearnIteration_ || @@ -698,8 +704,8 @@ namespace nupic } for (UInt i = 0; i < actualValues_.size(); i++) { - if (actualValues_.at(i) != other.actualValues_.at(i) || - actualValuesSet_.at(i) != other.actualValuesSet_.at(i)) + if (fabs(actualValues_[i] - other.actualValues_[i]) > 0.000001 || + fabs(actualValuesSet_[i] - other.actualValuesSet_[i]) > 0.00001) { return false; } diff --git a/src/nupic/algorithms/FastClaClassifier.hpp b/src/nupic/algorithms/FastClaClassifier.hpp index 85054e9bde..711ee76b6f 100644 --- a/src/nupic/algorithms/FastClaClassifier.hpp +++ b/src/nupic/algorithms/FastClaClassifier.hpp @@ -138,11 +138,21 @@ namespace nupic */ void write(ClaClassifierProto::Builder& proto) const; + /** + * Save the state to the stream. + */ + void write(ostream& proto) const; + /** * Load state from reader. */ void read(ClaClassifierProto::Reader& proto); + /** + * Load state from stream. + */ + void read(istream& stream); + /** * Compare the other instance to this one. * diff --git a/src/test/unit/algorithms/FastCLAClassifierTest.cpp b/src/test/unit/algorithms/FastCLAClassifierTest.cpp index 06e4c2b7a8..61a21ce8cb 100644 --- a/src/test/unit/algorithms/FastCLAClassifierTest.cpp +++ b/src/test/unit/algorithms/FastCLAClassifierTest.cpp @@ -135,4 +135,34 @@ namespace ASSERT_TRUE(result1 == result2); } + TEST(FastCLAClassifierTest, WriteRead) + { + vector steps; + steps.push_back(1); + FastCLAClassifier c1 = FastCLAClassifier(steps, 0.1, 0.1, 0); + FastCLAClassifier c2 = FastCLAClassifier(steps, 0.1, 0.1, 0); + + // Create a vector of input bit indices + vector input1; + input1.push_back(1); + input1.push_back(5); + input1.push_back(9); + ClassifierResult result; + c1.fastCompute(0, input1, 4, 34.7, false, true, true, &result); + + { + stringstream ss; + c1.write(ss); + c2.read(ss); + } + + ASSERT_TRUE(c1 == c2); + + ClassifierResult result1, result2; + c1.fastCompute(1, input1, 4, 35.7, false, true, true, &result1); + c2.fastCompute(1, input1, 4, 35.7, false, true, true, &result2); + + ASSERT_TRUE(result1 == result2); + } + } // end namespace From c8bc8f5026353c428166ddcbb8ee693b8a62141c Mon Sep 17 00:00:00 2001 From: Scott Purdy Date: Fri, 10 Apr 2015 11:31:07 -0700 Subject: [PATCH 095/100] Rename classifier proto. --- src/nupic/proto/{CLAClassifier.capnp => ClaClassifier.capnp} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/nupic/proto/{CLAClassifier.capnp => ClaClassifier.capnp} (100%) diff --git a/src/nupic/proto/CLAClassifier.capnp b/src/nupic/proto/ClaClassifier.capnp similarity index 100% rename from src/nupic/proto/CLAClassifier.capnp rename to src/nupic/proto/ClaClassifier.capnp From 13fee5f8d667a1a80a54164ec08ce44e83d4d379 Mon Sep 17 00:00:00 2001 From: Matthew Taylor Date: Fri, 10 Apr 2015 11:38:33 -0700 Subject: [PATCH 096/100] Downcasing 'Windows64' to 'windows64' for consistency. --- appveyor.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 01092b5d48..1e287e42e3 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -126,9 +126,9 @@ after_build: # This packages via CMakeList CPack settings (Tar.Gzip for SW upload) # msbuild $env:MSBuildOptions PACKAGE.vcxproj - 7z a -ttar -y -bd nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar . + 7z a -ttar -y -bd nupic_core-$env:APPVEYOR_REPO_COMMIT-windows64.tar . - 7z a -tgzip -y -bd ..\..\nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar.gz nupic_core-$env:APPVEYOR_REPO_COMMIT-Windows64.tar + 7z a -tgzip -y -bd ..\..\nupic_core-$env:APPVEYOR_REPO_COMMIT-windows64.tar.gz nupic_core-$env:APPVEYOR_REPO_COMMIT-windows64.tar artifacts: - path: '**\*.tar.gz' # find all Gz(ip) packages recursively @@ -143,7 +143,7 @@ deploy: bucket: "artifacts.numenta.org" region: us-west-2 set_public: true - artifact: "nupic_core-$(APPVEYOR_REPO_COMMIT)-Windows64.tar.gz" + artifact: "nupic_core-$(APPVEYOR_REPO_COMMIT)-windows64.tar.gz" folder: "numenta/nupic.core" on: branch: master \ No newline at end of file From d30951ece334f634b1da5f669feecde02e7277da Mon Sep 17 00:00:00 2001 From: Scott Purdy Date: Mon, 13 Apr 2015 09:37:23 -0700 Subject: [PATCH 097/100] Update case for capnp file. --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2b99a3d156..7e4b7151a3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -308,7 +308,7 @@ include_directories(${CAPNP_INCLUDE_DIRS}) # when compiling later on. set(CAPNP_SPECS nupic/proto/BitHistory.capnp - nupic/proto/CLAClassifier.capnp + nupic/proto/ClaClassifier.capnp nupic/proto/RandomProto.capnp nupic/proto/SparseBinaryMatrixProto.capnp nupic/proto/SparseMatrixProto.capnp From cd1bf16ad9c6c71cf63f59bb3a72fb31ddaa102f Mon Sep 17 00:00:00 2001 From: Matthew Taylor Date: Mon, 13 Apr 2015 15:25:49 -0700 Subject: [PATCH 098/100] AppVeyor config shallow_clone: false --- appveyor.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 1e287e42e3..7510c78ce4 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -37,7 +37,9 @@ init: clone_folder: c:\projects\nupic-core clone_depth: 50 -shallow_clone: true +# Can't have a shallow clone because the CMake process will be calling into +# git to write the current SHA into the binaries. +shallow_clone: false #---------------------------------# # build configuration # @@ -146,4 +148,4 @@ deploy: artifact: "nupic_core-$(APPVEYOR_REPO_COMMIT)-windows64.tar.gz" folder: "numenta/nupic.core" on: - branch: master \ No newline at end of file + branch: master From 327c69ee7d347e34e4961784966adf2435ecbc53 Mon Sep 17 00:00:00 2001 From: Scott Purdy Date: Mon, 13 Apr 2015 12:54:46 -0700 Subject: [PATCH 099/100] Explicitly cast string type for MSVC. --- src/nupic/algorithms/BitHistory.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nupic/algorithms/BitHistory.cpp b/src/nupic/algorithms/BitHistory.cpp index 7f6af2cb53..87f97d8eb1 100644 --- a/src/nupic/algorithms/BitHistory.cpp +++ b/src/nupic/algorithms/BitHistory.cpp @@ -176,7 +176,7 @@ namespace nupic } void BitHistory::write(BitHistoryProto::Builder& proto) const { - proto.setId(id_); + proto.setId(id_.c_str()); auto statsList = proto.initStats(stats_.size()); UInt i = 0; @@ -196,7 +196,7 @@ namespace nupic void BitHistory::read(BitHistoryProto::Reader& proto) { - id_ = proto.getId(); + id_ = proto.getId().cStr(); stats_.clear(); for (auto stat : proto.getStats()) From adde6ab071504758915ee7bfff0e0e6a96bcbdbb Mon Sep 17 00:00:00 2001 From: david-ragazzi Date: Fri, 17 Apr 2015 16:29:37 -0300 Subject: [PATCH 100/100] Remove FlatSpatialPooler --- src/CMakeLists.txt | 3 - src/nupic/algorithms/FlatSpatialPooler.cpp | 260 -------------- src/nupic/algorithms/FlatSpatialPooler.hpp | 130 ------- .../unit/algorithms/FlatSpatialPoolerTest.cpp | 334 ------------------ .../unit/algorithms/FlatSpatialPoolerTest.hpp | 69 ---- 5 files changed, 796 deletions(-) delete mode 100644 src/nupic/algorithms/FlatSpatialPooler.cpp delete mode 100644 src/nupic/algorithms/FlatSpatialPooler.hpp delete mode 100644 src/test/unit/algorithms/FlatSpatialPoolerTest.cpp delete mode 100644 src/test/unit/algorithms/FlatSpatialPoolerTest.hpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7e4b7151a3..e29abd3852 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -344,7 +344,6 @@ ADD_LIBRARY(${LIB_STATIC_NUPICCORE} nupic/algorithms/CondProbTable.cpp nupic/algorithms/Connections.cpp nupic/algorithms/FastClaClassifier.cpp - nupic/algorithms/FlatSpatialPooler.cpp nupic/algorithms/GaborNode.cpp nupic/algorithms/ImageSensorLite.cpp nupic/algorithms/InSynapse.cpp @@ -481,7 +480,6 @@ add_executable(${EXECUTABLE_GTESTS} test/unit/algorithms/CondProbTableTest.cpp test/unit/algorithms/ConnectionsTest.cpp test/unit/algorithms/FastCLAClassifierTest.cpp - test/unit/algorithms/FlatSpatialPoolerTest.cpp test/unit/algorithms/NearestNeighborUnitTest.cpp test/unit/algorithms/SpatialPoolerTest.cpp test/unit/engine/InputTest.cpp @@ -533,7 +531,6 @@ add_custom_target(tests_unit set(TEST_HEADERS test/unit/algorithms/CondProbTableTest.hpp test/unit/algorithms/ConnectionsTest.hpp - test/unit/algorithms/FlatSpatialPoolerTest.hpp test/unit/algorithms/NearestNeighborUnitTest.hpp test/unit/algorithms/SpatialPoolerTest.hpp test/unit/engine/InputTest.hpp diff --git a/src/nupic/algorithms/FlatSpatialPooler.cpp b/src/nupic/algorithms/FlatSpatialPooler.cpp deleted file mode 100644 index a4f098964d..0000000000 --- a/src/nupic/algorithms/FlatSpatialPooler.cpp +++ /dev/null @@ -1,260 +0,0 @@ -/* --------------------------------------------------------------------- - * Numenta Platform for Intelligent Computing (NuPIC) - * Copyright (C) 2013, Numenta, Inc. Unless you have an agreement - * with Numenta, Inc., for a separate license for this software code, the - * following terms and conditions apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 3 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses. - * - * http://numenta.org/licenses/ - * ---------------------------------------------------------------------- - */ - -/** @file - * Implementation of FlatSpatialPooler - */ - -#include -#include -#include -#include -#include -#include -#include - -using namespace std; -using namespace nupic; -using namespace nupic::algorithms::spatial_pooler; - - -Real FlatSpatialPooler::getMinDistance() -{ - return minDistance_; -} - -void FlatSpatialPooler::setMinDistance(Real minDistance) -{ - minDistance_ = minDistance; -} - -bool FlatSpatialPooler::getRandomSP() -{ - return randomSP_; -} - -void FlatSpatialPooler::setRandomSP(bool randomSP) -{ - randomSP_ = randomSP; -} - - -void FlatSpatialPooler::compute(UInt inputArray[], bool learn, - UInt activeArray[], bool stripNeverLearned) -{ - if (randomSP_) { - learn = false; - } - - updateBookeepingVars_(learn); - calculateOverlap_(inputArray, overlaps_); - calculateOverlapPct_(overlaps_, overlapsPct_); - - selectHighTierColumns_(overlapsPct_, highTier_); - selectVirginColumns_(virgin_); - - if (spVerbosity_ > 2) { - std::cout << "---------CPP FlatSpatialPooler::compute() ------------\n"; - std::cout << "iterationNum_ = " << iterationNum_ << std::endl; - std::cout << "minDistance_ = " << minDistance_ << std::endl; - std::cout << "overlapsPct:\n"; - printState(overlapsPct_); - std::cout << "CPP highTier columns:\n"; - printState(highTier_); - std::cout << "CPP virgin columns:\n"; - printState(virgin_); - std::cout << "-----------------------------------------------------\n"; - } - - if (learn) { - boostOverlaps_(overlaps_, boostedOverlaps_); - } else { - boostedOverlaps_.assign(overlaps_.begin(), overlaps_.end()); - } - - Real bonus = *max_element(boostedOverlaps_.begin(), - boostedOverlaps_.end()) + 1; - - // Ensure one of the high tier columns win - // If learning is on, ensure an unlearned column wins - if (learn) { - addBonus_(boostedOverlaps_, bonus, virgin_, true); - } - addBonus_(boostedOverlaps_, bonus, highTier_, false); - - inhibitColumns_(boostedOverlaps_, activeColumns_); - toDense_(activeColumns_, activeArray, numColumns_); - - if (learn) { - adaptSynapses_(inputArray, activeColumns_); - updateDutyCycles_(overlaps_, activeArray); - bumpUpWeakColumns_(); - updateBoostFactors_(); - - if (isUpdateRound_()) { - updateInhibitionRadius_(); - updateMinDutyCycles_(); - } - } else if (stripNeverLearned) { - stripUnlearnedColumns(activeArray); - } -} - -void FlatSpatialPooler::compute(UInt inputArray[], bool learn, - UInt activeArray[]) -{ - compute(inputArray, learn, activeArray, true); -} - -void FlatSpatialPooler::addBonus_( - vector& vec, Real bonus, vector& indices, bool replace) -{ - for (auto & indice : indices) { - UInt index = indice; - if (replace) { - vec[index] = bonus; - } else { - vec[index] += bonus; - } - } -} - -void FlatSpatialPooler::selectVirginColumns_(vector& virgin) -{ - virgin.clear(); - for (UInt i = 0; i < numColumns_; i++) { - if (activeDutyCycles_[i] == 0) { - virgin.push_back(i); - } - } -} - -void FlatSpatialPooler::selectHighTierColumns_(vector& overlapsPct, - vector &highTier) -{ - highTier.clear(); - for (UInt i = 0; i < numColumns_; i++) { - if (overlapsPct[i] >= (1.0 - minDistance_)) { - highTier.push_back(i); - } - } -} - -void FlatSpatialPooler::initializeFlat( - UInt numInputs, UInt numColumns, - Real potentialPct, Real localAreaDensity, - UInt numActiveColumnsPerInhArea, UInt stimulusThreshold, - Real synPermInactiveDec, Real synPermActiveInc, Real synPermConnected, - Real minPctOverlapDutyCycles, Real minPctActiveDutyCycles, - UInt dutyCyclePeriod, Real maxBoost, Real minDistance, bool randomSP, - Int seed, UInt spVerbosity) -{ - // call parent class initialize - vector inputDimensions, columnDimensions; - inputDimensions.push_back(numInputs); - columnDimensions.push_back(numColumns); - - initialize( - inputDimensions, - columnDimensions, - numInputs, - potentialPct, - true, // Global inhibition is always true in the flat pooler - localAreaDensity, - numActiveColumnsPerInhArea, - stimulusThreshold, - synPermInactiveDec, - synPermActiveInc, - synPermConnected, - minPctOverlapDutyCycles, - minPctActiveDutyCycles, - dutyCyclePeriod, - maxBoost, - seed, - spVerbosity, - true); // Set wrapAround to true - - minDistance_ = minDistance; - randomSP_ = randomSP; - - activeDutyCycles_.assign(numColumns_, 1); - boostFactors_.assign(numColumns_, maxBoost); - - // For high tier to work we need to set the min duty cycles to be non-zero - // This will ensure that columns with 0 active duty cycle get high boost - // in the beginning. - minOverlapDutyCycles_.assign(numColumns_, 1e-6); - minActiveDutyCycles_.assign(numColumns_, 1e-6); - - if (spVerbosity_ > 0) { - printFlatParameters(); - } - -} - - -void FlatSpatialPooler::save(ostream& outStream) const -{ - - SpatialPooler::save(outStream); - - - // Write a starting marker and version. - outStream << "FlatSpatialPooler" << endl; - - outStream << minDistance_ << " " - << randomSP_ << endl; - - outStream << "~FlatSpatialPooler" << endl; - -} - -void FlatSpatialPooler::load(istream& inStream) -{ - - SpatialPooler::load(inStream); - - // Check the marker - string marker; - inStream >> marker; - NTA_CHECK(marker == "FlatSpatialPooler"); - - inStream >> minDistance_ - >> randomSP_; - - inStream >> marker; - NTA_CHECK(marker == "~FlatSpatialPooler"); -} - - -//---------------------------------------------------------------------- -// Debugging helpers -//---------------------------------------------------------------------- - -// Print the creation parameters specific to this class -void FlatSpatialPooler::printFlatParameters() -{ - std::cout << " CPP FlatSpatialPooler Parameters\n"; - std::cout - << "minDistance = " << getMinDistance() << std::endl - << "randomSP = " << getRandomSP() << std::endl; -} diff --git a/src/nupic/algorithms/FlatSpatialPooler.hpp b/src/nupic/algorithms/FlatSpatialPooler.hpp deleted file mode 100644 index bd58c7b098..0000000000 --- a/src/nupic/algorithms/FlatSpatialPooler.hpp +++ /dev/null @@ -1,130 +0,0 @@ -/* --------------------------------------------------------------------- - * Numenta Platform for Intelligent Computing (NuPIC) - * Copyright (C) 2013, Numenta, Inc. Unless you have an agreement - * with Numenta, Inc., for a separate license for this software code, the - * following terms and conditions apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 3 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses. - * - * http://numenta.org/licenses/ - * ---------------------------------------------------------------------- - */ - -/** @file - * Definitions for the Spatial Pooler - */ - -#ifndef NTA_flat_spatial_pooler_HPP -#define NTA_flat_spatial_pooler_HPP - -#include -#include -#include -#include -#include -#include - -using namespace std; - -namespace nupic { - namespace algorithms { - namespace spatial_pooler { - - - ///////////////////////////////////////////////////////////////////////// - /// CLA flat spatial pooler implementation in C++. - /// - /// @b Responsibility - /// The Spatial Pooler is responsible for creating a sparse distributed - /// representation of the input. It computes the set of active columns. - /// It maintains the state of the proximal dendrites between the columns - /// and the inputs bits and keeps track of the activity and overlap - /// duty cycles - /// - /// @b Description - /// Todo. - /// - ///////////////////////////////////////////////////////////////////////// - class FlatSpatialPooler : public SpatialPooler { - public: - FlatSpatialPooler() {} - - virtual ~FlatSpatialPooler() {} - - virtual void save(ostream& outStream) const override; - virtual void load(istream& inStream) override; - - virtual UInt version() const override { - return version_; - }; - - - Real getMinDistance(); - void setMinDistance(Real minDistance); - bool getRandomSP(); - void setRandomSP(bool randomSP); - - virtual void compute(UInt inputVector[], bool learn, - UInt activeVector[], bool stripNeverLearned) override; - - virtual void compute(UInt inputVector[], bool learn, - UInt activeVector[]) override; - - void addBonus_(vector& vec, Real bonus, - vector& indices, bool replace); - - void selectVirginColumns_(vector& virgin); - - void selectHighTierColumns_(vector& overlapsPct, - vector &highTier); - - - virtual void initializeFlat( - UInt numInputs, - UInt numColumns, - Real potentialPct = 0.5, - Real localAreaDensity=0, - UInt numActiveColumnsPerInhArea=10, - UInt stimulusThreshold=0, - Real synPermInactiveDec=0.01, - Real synPermActiveInc=0.1, - Real synPermConnected=0.1, - Real minPctOverlapDutyCycles=0.001, - Real minPctActiveDutyCycles=0.001, - UInt dutyCyclePeriod=1000, - Real maxBoost=10.0, - Real minDistance=0.0, - bool randomSP=false, - Int seed=-1, - UInt spVerbosity=0); - - //------------------------------------------------------------------- - // Debugging helpers - //------------------------------------------------------------------- - - // Print the creation parameters specific to this class - void printFlatParameters(); - - - protected: - Real minDistance_; - bool randomSP_; - - vector highTier_; - vector virgin_; - - }; - } // end namespace spatial_pooler - } // end namespace algorithms -} // end namespace nupic -#endif // NTA_flat_spatial_pooler_HPP diff --git a/src/test/unit/algorithms/FlatSpatialPoolerTest.cpp b/src/test/unit/algorithms/FlatSpatialPoolerTest.cpp deleted file mode 100644 index 7f6904cb9b..0000000000 --- a/src/test/unit/algorithms/FlatSpatialPoolerTest.cpp +++ /dev/null @@ -1,334 +0,0 @@ -/* --------------------------------------------------------------------- - * Numenta Platform for Intelligent Computing (NuPIC) - * Copyright (C) 2013, Numenta, Inc. Unless you have an agreement - * with Numenta, Inc., for a separate license for this software code, the - * following terms and conditions apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 3 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses. - * - * http://numenta.org/licenses/ - * --------------------------------------------------------------------- - */ - -/** @file - * Implementation of unit tests for SpatialPooler - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include "FlatSpatialPoolerTest.hpp" - -using namespace std; -using namespace nupic::algorithms::spatial_pooler; - -namespace nupic { - - void FlatSpatialPoolerTest::print_vec(UInt arr[], UInt n) - { - for (UInt i = 0; i < n; i++) { - cout << arr[i] << " "; - } - cout << endl; - } - - void FlatSpatialPoolerTest::print_vec(Real arr[], UInt n) - { - for (UInt i = 0; i < n; i++) { - cout << arr[i] << " "; - } - cout << endl; - } - - void FlatSpatialPoolerTest::print_vec(vector vec) - { - for (auto & elem : vec) { - cout << elem << " "; - } - cout << endl; - } - - void FlatSpatialPoolerTest::print_vec(vector vec) - { - for (auto & elem : vec) { - cout << elem << " "; - } - cout << endl; - } - - bool FlatSpatialPoolerTest::almost_eq(Real a, Real b) - { - Real diff = a - b; - return (diff > -1e-5 && diff < 1e-5); - } - - bool FlatSpatialPoolerTest::check_vector_eq(UInt arr[], vector vec) - { - for (UInt i = 0; i < vec.size(); i++) { - if (arr[i] != vec[i]) { - return false; - } - } - return true; - } - - bool FlatSpatialPoolerTest::check_vector_eq(Real arr[], vector vec) - { - for (UInt i = 0; i < vec.size(); i++) { - if (!almost_eq(arr[i],vec[i])) { - return false; - } - } - return true; - } - - bool FlatSpatialPoolerTest::check_vector_eq(UInt arr1[], UInt arr2[], UInt n) - { - for (UInt i = 0; i < n; i++) { - if (arr1[i] != arr2[i]) { - return false; - } - } - return true; - } - - bool FlatSpatialPoolerTest::check_vector_eq(Real arr1[], Real arr2[], UInt n) - { - for (UInt i = 0; i < n; i++) { - if (!almost_eq(arr1[i], arr2[i])) { - return false; - } - } - return true; - } - - bool FlatSpatialPoolerTest::check_vector_eq(vector vec1, vector vec2) - { - if (vec1.size() != vec2.size()) { - return false; - } - for (UInt i = 0; i < vec1.size(); i++) { - if (vec1[i] != vec2[i]) { - return false; - } - } - return true; - } - - void FlatSpatialPoolerTest::RunTests() - { - testSelectVirgin(); - testSelectHighTierColumns(); - testAddBonus(); - testSerialize(); - } - - void FlatSpatialPoolerTest::testAddBonus() - { - UInt numInputs = 5; - UInt numColumns = 7; - FlatSpatialPooler fsp = FlatSpatialPooler(); - fsp.initializeFlat(numInputs, numColumns); - vector indices; - vector vec; - Real bonus; - bool replace; - - indices.clear(); - indices.push_back(1); - indices.push_back(4); - indices.push_back(6); - bonus = 5; - replace = false; - Real initArray1[] = {10, 10, 10, 10, 10, 10, 10}; - Real trueArray1[] = {10, 15, 10, 10, 15, 10, 15}; - vec.assign(initArray1, initArray1 + numColumns); - fsp.addBonus_(vec, bonus, indices, replace); - NTA_CHECK(check_vector_eq(trueArray1, vec)); - - indices.clear(); - indices.push_back(1); - indices.push_back(4); - indices.push_back(6); - bonus = 4; - replace = true; - Real initArray2[] = {10, 10, 10, 10, 10, 10, 10}; - Real trueArray2[] = {10, 4, 10, 10, 4, 10, 4}; - vec.assign(initArray2, initArray2 + numColumns); - fsp.addBonus_(vec, bonus, indices, replace); - NTA_CHECK(check_vector_eq(trueArray2, vec)); - - indices.clear(); - indices.push_back(1); - indices.push_back(2); - indices.push_back(3); - indices.push_back(4); - indices.push_back(6); - bonus = 5000; - replace = false; - Real initArray3[] = {10, 10, 10, 10, 10, 10, 10}; - Real trueArray3[] = {10, 5010, 5010, 5010, 5010, 10, 5010}; - vec.assign(initArray3, initArray3 + numColumns); - fsp.addBonus_(vec, bonus, indices, replace); - NTA_CHECK(check_vector_eq(trueArray3, vec)); - - indices.clear(); - bonus = 1; - replace = true; - Real initArray4[] = {0, 123, 456, 678, 999, 1111, 9834}; - Real trueArray4[] = {0, 123, 456, 678, 999, 1111, 9834}; - vec.assign(initArray4, initArray4 + numColumns); - fsp.addBonus_(vec, bonus, indices, replace); - NTA_CHECK(check_vector_eq(trueArray4, vec)); - - indices.clear(); - indices.push_back(1); - indices.push_back(2); - indices.push_back(3); - indices.push_back(4); - indices.push_back(6); - bonus = 5000; - replace = false; - Real initArray5[] = {10, 10, 10, 10, 10, 10, 10}; - Real trueArray5[] = {10, 5010, 5010, 5010, 5010, 10, 5010}; - vec.assign(initArray5, initArray5 + numColumns); - fsp.addBonus_(vec, bonus, indices, replace); - NTA_CHECK(check_vector_eq(trueArray5, vec)); - } - - void FlatSpatialPoolerTest::testSelectHighTierColumns() - { - UInt numInputs = 5; - UInt numColumns = 10; - FlatSpatialPooler fsp = FlatSpatialPooler(); - fsp.initializeFlat(numInputs, numColumns); - vector highTier, highTierDense; - vector overlapsPct; - Real minDistance; - - minDistance = 0.1; - fsp.setMinDistance(minDistance); - Real overlapsPctArray1[] = {1.0, 0.95, 0.99, 0.88, 0.87, 0.7, 0.1, 0, 0.3, 0.9001}; - UInt trueHighTier1[] = {1, 1, 1, 0, 0, 0, 0, 0, 0, 1}; - overlapsPct.assign(overlapsPctArray1,overlapsPctArray1 + numColumns); - - fsp.selectHighTierColumns_(overlapsPct, highTier); - highTierDense.assign(numColumns, 0); - for (auto & elem : highTier) { - highTierDense[elem] = 1; - } - NTA_CHECK(check_vector_eq(trueHighTier1, highTierDense)); - - minDistance = 0.25; - fsp.setMinDistance(minDistance); - Real overlapsPctArray2[] = {1.0, 0.05, 0.19, 0.88, 0.77, 0.81, 0.61, 0.64, 0.73, 0.8001}; - UInt trueHighTier2[] = {1, 0, 0, 1, 1, 1, 0, 0, 0, 1}; - overlapsPct.assign(overlapsPctArray2,overlapsPctArray2 + numColumns); - - fsp.selectHighTierColumns_(overlapsPct, highTier); - highTierDense.assign(numColumns, 0); - for (auto & elem : highTier) { - highTierDense[elem] = 1; - } - NTA_CHECK(check_vector_eq(trueHighTier2, highTierDense)); - - minDistance = 1.0; - fsp.setMinDistance(minDistance); - Real overlapsPctArray3[] = {1.0, 0.05, 0.19, 0.88, 0.77, 0.81, 0.61, 0.64, 0.73, 0.8001}; - UInt trueHighTier3[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; - overlapsPct.assign(overlapsPctArray3,overlapsPctArray3 + numColumns); - - fsp.selectHighTierColumns_(overlapsPct, highTier); - highTierDense.assign(numColumns, 0); - for (auto & elem : highTier) { - highTierDense[elem] = 1; - } - NTA_CHECK(check_vector_eq(trueHighTier3, highTierDense)); - - minDistance = 0; - fsp.setMinDistance(minDistance); - Real overlapsPctArray4[] = {1.0, 0.05, 0.99, 0.98, 1.0, 0, 1.0, 0.64, 0.73, 0.8001}; - UInt trueHighTier4[] = {1, 0, 0, 0, 1, 0, 1, 0, 0, 0}; - overlapsPct.assign(overlapsPctArray4,overlapsPctArray4 + numColumns); - - fsp.selectHighTierColumns_(overlapsPct, highTier); - highTierDense.assign(numColumns, 0); - for (auto & elem : highTier) { - highTierDense[elem] = 1; - } - NTA_CHECK(check_vector_eq(trueHighTier4, highTierDense)); - } - - void FlatSpatialPoolerTest::testSelectVirgin() - { - UInt numInputs = 5; - UInt numColumns = 10; - FlatSpatialPooler fsp = FlatSpatialPooler(); - fsp.initializeFlat(numInputs, numColumns); - vector virgin; - - Real activeDutyArr1[] = {0.9, 0.8, 0.7, 0, 0.6, 0.001, 0, 0.01, 0, 0.09}; - UInt trueVirgin1[] = {3,6,8}; - fsp.setActiveDutyCycles(activeDutyArr1); - - fsp.selectVirginColumns_(virgin); - NTA_CHECK(check_vector_eq(trueVirgin1, virgin)); - - Real activeDutyArr2[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - UInt trueVirgin2[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; - fsp.setActiveDutyCycles(activeDutyArr2); - - fsp.selectVirginColumns_(virgin); - NTA_CHECK(check_vector_eq(trueVirgin2, virgin)); - - Real activeDutyArr3[] = {0.9, 0.8, 0.7, 0.3, 0.6, 0.001, 0.003, 0.01, 0.12, 0.09}; - fsp.setActiveDutyCycles(activeDutyArr3); - - fsp.selectVirginColumns_(virgin); - NTA_CHECK(virgin.size() == 0); - } - - void FlatSpatialPoolerTest::testSerialize() - { - string filename = "FlatSpatialPoolerSerialization.tmp"; - FlatSpatialPooler sp_orig; - UInt numInputs = 5; - UInt numColumns = 10; - FlatSpatialPooler fsp_orig = FlatSpatialPooler(); - fsp_orig.initializeFlat(numInputs, numColumns); - fsp_orig.setRandomSP(true); - fsp_orig.setMinDistance(0.3); - - ofstream outfile; - outfile.open (filename.c_str()); - fsp_orig.save(outfile); - outfile.close(); - - FlatSpatialPooler fsp_dest; - ifstream infile (filename.c_str()); - fsp_dest.load(infile); - infile.close(); - - NTA_CHECK(fsp_orig.getMinDistance() == fsp_dest.getMinDistance()); - NTA_CHECK(fsp_orig.getRandomSP() == fsp_dest.getRandomSP()); - - int ret = std::remove(filename.c_str()); - NTA_ASSERT(ret == 0); // << " FlatSpatialPooler.serialization failed. " << std::endl; - } - -} // end namespace nupic diff --git a/src/test/unit/algorithms/FlatSpatialPoolerTest.hpp b/src/test/unit/algorithms/FlatSpatialPoolerTest.hpp deleted file mode 100644 index 1042654d6b..0000000000 --- a/src/test/unit/algorithms/FlatSpatialPoolerTest.hpp +++ /dev/null @@ -1,69 +0,0 @@ -/* --------------------------------------------------------------------- - * Numenta Platform for Intelligent Computing (NuPIC) - * Copyright (C) 2013, Numenta, Inc. Unless you have an agreement - * with Numenta, Inc., for a separate license for this software code, the - * following terms and conditions apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 3 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses. - * - * http://numenta.org/licenses/ - * --------------------------------------------------------------------- - */ - -/** @file - * Definitions for SpatialPoolerTest - */ - -#ifndef NTA_FLAT_SPATIAL_POOLER_TEST -#define NTA_FLAT_SPATIAL_POOLER_TEST - -#include -#include - -using namespace nupic::algorithms::spatial_pooler; - -namespace nupic { - - class FlatSpatialPoolerTest : public Tester - { - public: - FlatSpatialPoolerTest() {} - virtual ~FlatSpatialPoolerTest() {} - - // Run all appropriate tests - virtual void RunTests() override; - - private: - void setup(SpatialPooler& sp, UInt numInputs, UInt numColumns); - bool check_vector_eq(UInt arr[], vector vec); - bool check_vector_eq(Real arr[], vector vec); - bool check_vector_eq(UInt arr1[], UInt arr2[], UInt n); - bool check_vector_eq(Real arr1[], Real arr2[], UInt n); - bool check_vector_eq(vector vec1, vector vec2); - bool almost_eq(Real a, Real b); - - void testSelectVirgin(); - void testSelectHighTierColumns(); - void testAddBonus(); - void testSerialize(); - - void print_vec(UInt arr[], UInt n); - void print_vec(Real arr[], UInt n); - void print_vec(vector vec); - void print_vec(vector vec); - - }; // end class SpatialPoolerTest - -} // end namespace nupic - -#endif // NTA_FLAT_SPATIAL_POOLER_TEST