htm-community / comportex

Hierarchical Temporal Memory in Clojure
154 stars 27 forks source link

You can't create a 2-region model with a 3D topology #9

Closed mrcslws closed 8 years ago

mrcslws commented 9 years ago

(require '[org.nfrac.comportex.demos.isolated-2d :as demo]) (demo/n-region-model 2) ==> NullPointerException from clojure.lang.Numbers/add

Fewer than 3 dimensions are getting passed into ThreeDTopology/index_of_coordinates

Before 5a860d8b590552ccdd2531134f65c103020aa80b, this code would cause a stack overflow, so this is just another layer of the onion.

I'm tentatively exploring the issue, but feel free to jump in if it's a no-brainer.

                  Numbers.java:  961  clojure.lang.Numbers/ops
                  Numbers.java:  126  clojure.lang.Numbers/add
                 topology.cljx:   83  org.nfrac.comportex.topology.ThreeDTopology/index_of_coordinates
                  columns.cljx:   61  org.nfrac.comportex.columns$uniform_ff_synapses$fn__11848/invoke
                      core.clj: 6353  clojure.core/mapv/fn
               ArrayChunk.java:   58  clojure.lang.ArrayChunk/reduce
                 protocols.clj:   98  clojure.core.protocols/fn
                 protocols.clj:   19  clojure.core.protocols/fn/G
                 protocols.clj:   31  clojure.core.protocols/seq-reduce
                 protocols.clj:   54  clojure.core.protocols/fn
                 protocols.clj:   13  clojure.core.protocols/fn/G
                      core.clj: 6289  clojure.core/reduce
                      core.clj: 6353  clojure.core/mapv
                  columns.cljx:   55  org.nfrac.comportex.columns$uniform_ff_synapses/invoke
                    cells.cljx:  638  org.nfrac.comportex.cells$layer_of_cells/invoke
                     core.cljx:   94  org.nfrac.comportex.core$sensory_region/invoke
                     core.cljx:  317  org.nfrac.comportex.core$region_network$fn__12331/invoke
                 protocols.clj:  143  clojure.core.protocols/fn
                 protocols.clj:   19  clojure.core.protocols/fn/G
                 protocols.clj:  147  clojure.core.protocols/fn
                 protocols.clj:   19  clojure.core.protocols/fn/G
                 protocols.clj:   31  clojure.core.protocols/seq-reduce
                 protocols.clj:   54  clojure.core.protocols/fn
                 protocols.clj:   13  clojure.core.protocols/fn/G
                      core.clj: 6289  clojure.core/reduce
                     core.cljx:  324  org.nfrac.comportex.core$region_network/invoke
                     core.cljx:  345  org.nfrac.comportex.core$regions_in_series/invoke
              isolated_2d.cljx:  111  org.nfrac.comportex.demos.isolated_2d$n_region_model/invoke
              isolated_2d.cljx:  108  org.nfrac.comportex.demos.isolated_2d$n_region_model/invoke
                          REPL:    1  user/eval19149
                 Compiler.java: 6703  clojure.lang.Compiler/eval
                 Compiler.java: 6666  clojure.lang.Compiler/eval
                      core.clj: 2927  clojure.core/eval
                      main.clj:  239  clojure.main/repl/read-eval-print/fn
                      main.clj:  239  clojure.main/repl/read-eval-print
                      main.clj:  257  clojure.main/repl/fn
                      main.clj:  257  clojure.main/repl
                   RestFn.java: 1523  clojure.lang.RestFn/invoke
        interruptible_eval.clj:   67  clojure.tools.nrepl.middleware.interruptible-eval/evaluate/fn
                      AFn.java:  152  clojure.lang.AFn/applyToHelper
                      AFn.java:  144  clojure.lang.AFn/applyTo
                      core.clj:  624  clojure.core/apply
                      core.clj: 1862  clojure.core/with-bindings*
                   RestFn.java:  425  clojure.lang.RestFn/invoke
        interruptible_eval.clj:   51  clojure.tools.nrepl.middleware.interruptible-eval/evaluate
        interruptible_eval.clj:  183  clojure.tools.nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
        interruptible_eval.clj:  152  clojure.tools.nrepl.middleware.interruptible-eval/run-next/fn
                      AFn.java:   22  clojure.lang.AFn/run
       ThreadPoolExecutor.java: 1142  java.util.concurrent.ThreadPoolExecutor/runWorker
       ThreadPoolExecutor.java:  617  java.util.concurrent.ThreadPoolExecutor$Worker/run
                   Thread.java:  745  java.lang.Thread/run
floybix commented 9 years ago

3D input needs to be catered for in uniform-ff-synapses, this creates synapses by mapping input topology to corresponding areas of column topology. We will eventually need similar functionality when growing distal synapses locally, as well as if we grow feed-forward synapses at run time.

We could use your squash-last-dimension to get the input and columns into the same dimensions before doing proportional scaling?... Maybe should have a function to translate a point in one topology to a corresponding nearest point on another topology?

On 4 December 2014 at 01:30, Marcus Lewis notifications@github.com wrote:

(require '[org.nfrac.comportex.demos.isolated-2d :as demo]) (demo/n-region-model 2) ==> NullPointerException from clojure.lang.Numbers/add

Fewer than 3 dimensions are getting passed into ThreeDTopology/index_of_coordinates

Before 5a860d8 https://github.com/nupic-community/comportex/commit/5a860d8b590552ccdd2531134f65c103020aa80b, this code would cause a stack overflow, so this is just another layer of the onion.

I'm tentatively exploring the issue, but feel free to jump in if it's a no-brainer.

              Numbers.java:  961  clojure.lang.Numbers/ops
              Numbers.java:  126  clojure.lang.Numbers/add
             topology.cljx:   83  org.nfrac.comportex.topology.ThreeDTopology/index_of_coordinates
              columns.cljx:   61  org.nfrac.comportex.columns$uniform_ff_synapses$fn__11848/invoke
                  core.clj: 6353  clojure.core/mapv/fn
           ArrayChunk.java:   58  clojure.lang.ArrayChunk/reduce
             protocols.clj:   98  clojure.core.protocols/fn
             protocols.clj:   19  clojure.core.protocols/fn/G
             protocols.clj:   31  clojure.core.protocols/seq-reduce
             protocols.clj:   54  clojure.core.protocols/fn
             protocols.clj:   13  clojure.core.protocols/fn/G
                  core.clj: 6289  clojure.core/reduce
                  core.clj: 6353  clojure.core/mapv
              columns.cljx:   55  org.nfrac.comportex.columns$uniform_ff_synapses/invoke
                cells.cljx:  638  org.nfrac.comportex.cells$layer_of_cells/invoke
                 core.cljx:   94  org.nfrac.comportex.core$sensory_region/invoke
                 core.cljx:  317  org.nfrac.comportex.core$region_network$fn__12331/invoke
             protocols.clj:  143  clojure.core.protocols/fn
             protocols.clj:   19  clojure.core.protocols/fn/G
             protocols.clj:  147  clojure.core.protocols/fn
             protocols.clj:   19  clojure.core.protocols/fn/G
             protocols.clj:   31  clojure.core.protocols/seq-reduce
             protocols.clj:   54  clojure.core.protocols/fn
             protocols.clj:   13  clojure.core.protocols/fn/G
                  core.clj: 6289  clojure.core/reduce
                 core.cljx:  324  org.nfrac.comportex.core$region_network/invoke
                 core.cljx:  345  org.nfrac.comportex.core$regions_in_series/invoke
          isolated_2d.cljx:  111  org.nfrac.comportex.demos.isolated_2d$n_region_model/invoke
          isolated_2d.cljx:  108  org.nfrac.comportex.demos.isolated_2d$n_region_model/invoke
                      REPL:    1  user/eval19149
             Compiler.java: 6703  clojure.lang.Compiler/eval
             Compiler.java: 6666  clojure.lang.Compiler/eval
                  core.clj: 2927  clojure.core/eval
                  main.clj:  239  clojure.main/repl/read-eval-print/fn
                  main.clj:  239  clojure.main/repl/read-eval-print
                  main.clj:  257  clojure.main/repl/fn
                  main.clj:  257  clojure.main/repl
               RestFn.java: 1523  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   67  clojure.tools.nrepl.middleware.interruptible-eval/evaluate/fn
                  AFn.java:  152  clojure.lang.AFn/applyToHelper
                  AFn.java:  144  clojure.lang.AFn/applyTo
                  core.clj:  624  clojure.core/apply
                  core.clj: 1862  clojure.core/with-bindings*
               RestFn.java:  425  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   51  clojure.tools.nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:  183  clojure.tools.nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
    interruptible_eval.clj:  152  clojure.tools.nrepl.middleware.interruptible-eval/run-next/fn
                  AFn.java:   22  clojure.lang.AFn/run
   ThreadPoolExecutor.java: 1142  java.util.concurrent.ThreadPoolExecutor/runWorker
   ThreadPoolExecutor.java:  617  java.util.concurrent.ThreadPoolExecutor$Worker/run
               Thread.java:  745  java.lang.Thread/run

— Reply to this email directly or view it on GitHub https://github.com/nupic-community/comportex/issues/9.

Felix Andrews / 安福立 http://www.neurofractal.org/felix/

floybix commented 9 years ago

Wait, I remember now what I was thinking. Typically we have a 2D column field receiving input from other 2D region(s) with an added 3rd dimension of cells. So it makes sense to do local topological mapping with only the first 2 dimensions, i.e. ignore the last (cell) dimension when calculating spatial location.

Not sure whether this really works when we are combining dimensions of several regions... but seems reasonable to just ignore the 3rd dimension rather than trying to get the whole hypercube to conform.

On 4 December 2014 at 09:07, Felix Andrews felix@nfrac.org wrote:

3D input needs to be catered for in uniform-ff-synapses, this creates synapses by mapping input topology to corresponding areas of column topology. We will eventually need similar functionality when growing distal synapses locally, as well as if we grow feed-forward synapses at run time.

We could use your squash-last-dimension to get the input and columns into the same dimensions before doing proportional scaling?... Maybe should have a function to translate a point in one topology to a corresponding nearest point on another topology?

On 4 December 2014 at 01:30, Marcus Lewis notifications@github.com wrote:

(require '[org.nfrac.comportex.demos.isolated-2d :as demo]) (demo/n-region-model 2) ==> NullPointerException from clojure.lang.Numbers/add

Fewer than 3 dimensions are getting passed into ThreeDTopology/index_of_coordinates

Before 5a860d8 https://github.com/nupic-community/comportex/commit/5a860d8b590552ccdd2531134f65c103020aa80b, this code would cause a stack overflow, so this is just another layer of the onion.

I'm tentatively exploring the issue, but feel free to jump in if it's a no-brainer.

              Numbers.java:  961  clojure.lang.Numbers/ops
              Numbers.java:  126  clojure.lang.Numbers/add
             topology.cljx:   83  org.nfrac.comportex.topology.ThreeDTopology/index_of_coordinates
              columns.cljx:   61  org.nfrac.comportex.columns$uniform_ff_synapses$fn__11848/invoke
                  core.clj: 6353  clojure.core/mapv/fn
           ArrayChunk.java:   58  clojure.lang.ArrayChunk/reduce
             protocols.clj:   98  clojure.core.protocols/fn
             protocols.clj:   19  clojure.core.protocols/fn/G
             protocols.clj:   31  clojure.core.protocols/seq-reduce
             protocols.clj:   54  clojure.core.protocols/fn
             protocols.clj:   13  clojure.core.protocols/fn/G
                  core.clj: 6289  clojure.core/reduce
                  core.clj: 6353  clojure.core/mapv
              columns.cljx:   55  org.nfrac.comportex.columns$uniform_ff_synapses/invoke
                cells.cljx:  638  org.nfrac.comportex.cells$layer_of_cells/invoke
                 core.cljx:   94  org.nfrac.comportex.core$sensory_region/invoke
                 core.cljx:  317  org.nfrac.comportex.core$region_network$fn__12331/invoke
             protocols.clj:  143  clojure.core.protocols/fn
             protocols.clj:   19  clojure.core.protocols/fn/G
             protocols.clj:  147  clojure.core.protocols/fn
             protocols.clj:   19  clojure.core.protocols/fn/G
             protocols.clj:   31  clojure.core.protocols/seq-reduce
             protocols.clj:   54  clojure.core.protocols/fn
             protocols.clj:   13  clojure.core.protocols/fn/G
                  core.clj: 6289  clojure.core/reduce
                 core.cljx:  324  org.nfrac.comportex.core$region_network/invoke
                 core.cljx:  345  org.nfrac.comportex.core$regions_in_series/invoke
          isolated_2d.cljx:  111  org.nfrac.comportex.demos.isolated_2d$n_region_model/invoke
          isolated_2d.cljx:  108  org.nfrac.comportex.demos.isolated_2d$n_region_model/invoke
                      REPL:    1  user/eval19149
             Compiler.java: 6703  clojure.lang.Compiler/eval
             Compiler.java: 6666  clojure.lang.Compiler/eval
                  core.clj: 2927  clojure.core/eval
                  main.clj:  239  clojure.main/repl/read-eval-print/fn
                  main.clj:  239  clojure.main/repl/read-eval-print
                  main.clj:  257  clojure.main/repl/fn
                  main.clj:  257  clojure.main/repl
               RestFn.java: 1523  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   67  clojure.tools.nrepl.middleware.interruptible-eval/evaluate/fn
                  AFn.java:  152  clojure.lang.AFn/applyToHelper
                  AFn.java:  144  clojure.lang.AFn/applyTo
                  core.clj:  624  clojure.core/apply
                  core.clj: 1862  clojure.core/with-bindings*
               RestFn.java:  425  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   51  clojure.tools.nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:  183  clojure.tools.nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
    interruptible_eval.clj:  152  clojure.tools.nrepl.middleware.interruptible-eval/run-next/fn
                  AFn.java:   22  clojure.lang.AFn/run
   ThreadPoolExecutor.java: 1142  java.util.concurrent.ThreadPoolExecutor/runWorker
   ThreadPoolExecutor.java:  617  java.util.concurrent.ThreadPoolExecutor$Worker/run
               Thread.java:  745  java.lang.Thread/run

— Reply to this email directly or view it on GitHub https://github.com/nupic-community/comportex/issues/9.

Felix Andrews / 安福立 http://www.neurofractal.org/felix/

Felix Andrews / 安福立 http://www.neurofractal.org/felix/