diff --git a/CommonCompilerConfig.cmake b/CommonCompilerConfig.cmake index 39a2813f50..bac44c1f33 100644 --- a/CommonCompilerConfig.cmake +++ b/CommonCompilerConfig.cmake @@ -341,7 +341,7 @@ else() set(optimization_flags_cc ${optimization_flags_cc} -pipe -O3) set(optimization_flags_lt ${optimization_flags_lt} -O3) if(NOT ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l") - set(optimization_flags_cc ${optimization_flags_cc} -mtune=generic) + set(optimization_flags_cc ${optimization_flags_cc} -march=native) endif() if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" AND NOT MINGW) set(optimization_flags_cc ${optimization_flags_cc} -fuse-ld=gold) diff --git a/src/examples/mnist/MNIST_SP.cpp b/src/examples/mnist/MNIST_SP.cpp index 35c46fae1b..57593ddaf1 100644 --- a/src/examples/mnist/MNIST_SP.cpp +++ b/src/examples/mnist/MNIST_SP.cpp @@ -67,7 +67,7 @@ class MNIST { public: UInt verbosity = 1; - const UInt train_dataset_iterations = 2u; //epochs somewhat help, at linear time + const UInt train_dataset_iterations = 1u; //epochs somewhat help, at linear time void setup() { diff --git a/src/htm/algorithms/SpatialPooler.cpp b/src/htm/algorithms/SpatialPooler.cpp index 2d1df6a536..50c641d260 100644 --- a/src/htm/algorithms/SpatialPooler.cpp +++ b/src/htm/algorithms/SpatialPooler.cpp @@ -766,7 +766,8 @@ void applyBoosting_(const UInt i, const Real boost, vector& output) { if(boost < htm::Epsilon) return; //skip for disabled boosting - output[i] = exp((targetDensity - actualDensity[i]) * boost); //TODO doc this code + //output[i] = exp((targetDensity - actualDensity[i]) * boost); //exponential boosting, default for Numenta + output[i] = log(actualDensity[i]) / log(targetDensity); } diff --git a/src/test/unit/algorithms/SpatialPoolerTest.cpp b/src/test/unit/algorithms/SpatialPoolerTest.cpp index ad720bd315..ea12af1851 100644 --- a/src/test/unit/algorithms/SpatialPoolerTest.cpp +++ b/src/test/unit/algorithms/SpatialPoolerTest.cpp @@ -980,24 +980,11 @@ TEST(SpatialPoolerTest, testUpdateBoostFactors) { sp.getBoostFactors(resultBoostFactors1.data()); ASSERT_TRUE(check_vector_eq(trueBoostFactors1, resultBoostFactors1)); - Real32 initActiveDutyCycles2[] = {0.1f, 0.3f, 0.02f, 0.04f, 0.7f, 0.12f}; - Real32 initBoostFactors2[] = {0, 0, 0, 0, 0, 0}; - vector trueBoostFactors2 = {3.10599f, 0.42035f, 6.91251f, - 5.65949f, 0.00769898f, 2.54297f}; - vector resultBoostFactors2(6, 0); - sp.setGlobalInhibition(false); - sp.setBoostStrength(10); - sp.setBoostFactors(initBoostFactors2); - sp.setActiveDutyCycles(initActiveDutyCycles2); - sp.updateBoostFactors_(); - sp.getBoostFactors(resultBoostFactors2.data()); - - ASSERT_TRUE(check_vector_eq(trueBoostFactors2, resultBoostFactors2)); Real32 initActiveDutyCycles3[] = {0.1f, 0.3f, 0.02f, 0.04f, 0.7f, 0.12f}; Real initBoostFactors3[] = {0, 0, 0, 0, 0, 0}; - vector trueBoostFactors3 = {1.25441f, 0.840857f, 1.47207f, - 1.41435f, 0.377822f, 1.20523f}; + vector trueBoostFactors3 = {1.49044f, 0.779321f, 2.53222f, + 2.08355f, 0.230873f, 1.37243f}; vector resultBoostFactors3(6, 0); sp.setWrapAround(true); sp.setGlobalInhibition(false); @@ -1011,10 +998,11 @@ TEST(SpatialPoolerTest, testUpdateBoostFactors) { ASSERT_TRUE(check_vector_eq(trueBoostFactors3, resultBoostFactors3)); + Real32 initActiveDutyCycles4[] = {0.1f, 0.3f, 0.02f, 0.04f, 0.7f, 0.12f}; Real32 initBoostFactors4[] = {0, 0, 0, 0, 0, 0}; - vector trueBoostFactors4 = {1.94773f, 0.263597f, 4.33476f, - 3.549f, 0.00482795f, 1.59467f}; + vector trueBoostFactors4 = {1.2851f, 0.67195f, 2.18334f, + 1.79649f, 0.199064f, 1.18334f}; vector resultBoostFactors4(6, 0); sp.setGlobalInhibition(true); sp.setBoostStrength(10); @@ -2103,14 +2091,16 @@ TEST(SpatialPoolerTest, testConstructorVsInitialize) { TEST(SpatialPoolerTest, ExactOutput) { // Silver is an SDR that is loaded by direct initalization from a vector. SDR silver_sdr({ 200 }); - SDR_sparse_t data = {23, 71, 113, 118, 129, 172, 178, 182, 185, 190}; + SDR_sparse_t data = { + 12, 51, 81, 113, 129, 133, 172, 175, 178, 190 + }; silver_sdr.setSparse(data); // Gold tests initalizing an SDR from a manually created string in JSON format. // hint: you can generate this string using // silver_sdr.save(std::cout, JSON); - string gold = "{\"dimensions\": [200],\"sparse\": [23,71,113,118,129,172,178,182,185,190]}"; + string gold = "{\"dimensions\": [200],\"sparse\": [12, 51, 81, 113, 129, 133, 172, 175, 178, 190]}"; std::stringstream gold_stream( gold ); SDR gold_sdr; gold_sdr.load( gold_stream, JSON );