Hello,

I saw that you used only 20 columns for the experiment. This is way too
small for spatial pooler. You cannot form a code that is both sparse and
distributed with 20 column. Typically we used 2048 columns with 40 columns
active at any time.

During learning, the active columns would change. This is normal. You can
turn off learning if you don't want the active columns to change after
learning.

Also, you said you want spatial pooler to learn "ASCII" code, what does
that mean exactly? There is no topology in the ASCII space. Do you mean to
assign a random SDR for each ASCII code? If that is what you want, please
consider using the SDRCategory encoder [1]. I am not sure whether you can
gain anything by training the spatial pooler here.

https://github.com/numenta/nupic/blob/master/src/nupic/encoders/sdrcategory.py

--
Yuwei Cui, PhD

Research Engineer, Numenta Inc.

On Tue, Apr 12, 2016 at 10:31 AM, 酒若霖 <[email protected]> wrote:

> Dear Intelligence Developers:
>
> * I'm learning about nupic. My name is jiurl.
>
> * I want nupic to learn ascii codes, and I want through this simple
> example to watch how the spatialpooler working.
>
> * The design of the sample is:
> 8 bits inputs.
> One input is a ascii code. for example, 'A' { 0,1,0,0,0,0,0,1 }, 'B' {
> 0,1,0,0,0,0,1,0 }.
>
> 20 columns.
>
> numActiveColumnsPerInhArea set to 3.
>
> I think after some training, every ascii code will have a unique active
> columns set.
>
> * problems:
> but I run the spatialpooler with a series of inputs.
> I found two problems:
> first, the differnt ascii codes, have the same active columns set.
> second, the same ascii code's active column set have been changed after
> some traning truns.
>
> * My main demand:
> I want spatialpooler to learn ascii code. How can I make it happen, or it
> couldn't been done?
> thanks thanks thanks for any help.
>
> * a real run's result:
>
> // inputs to train SpatialPooler.
>   vector< vector<int> > inputs = {
>       { 0,1,0,0,0,0,0,1 }, //A
>       { 0,1,0,0,0,0,0,1 }, //A
>       { 0,1,0,0,0,0,0,1 }, //A
>       { 0,1,0,0,0,0,0,1 }, //A
>       { 0,1,0,0,0,0,0,1 }, //A
>       { 0,1,0,0,0,0,0,1 }, //A
>       { 0,1,0,0,0,0,0,1 }, //A
>       { 0,1,0,0,0,0,0,1 }, //A
>       { 0,1,0,0,0,0,0,1 }, //A
>       { 0,1,0,0,0,0,0,1 }, //A
>       { 0,1,0,0,1,1,1,1 }, //O
>       { 0,1,0,0,1,1,1,1 }, //O
>       { 0,1,0,0,1,1,1,1 }, //O
>       { 0,1,0,0,1,1,1,1 }, //O
>       { 0,1,0,0,1,1,1,1 }, //O
>       { 0,1,0,0,1,1,1,1 }, //O
>       { 0,1,0,0,1,1,1,1 }, //O
>       { 0,1,0,0,1,0,1,1 }, //K
>       { 0,1,0,0,1,0,1,1 }, //K
>       { 0,1,0,0,1,0,1,1 }, //K
>       { 0,1,0,0,1,0,1,1 }, //K
>       { 0,1,0,0,1,0,1,1 }, //K
>       { 0,1,0,0,1,0,1,1 }, //K
>       { 0,1,0,0,0,0,1,0 }, //B
>       { 0,1,0,0,0,0,1,1 }, //C
>       { 0,1,0,0,0,1,0,0 }, //D
>       { 0,1,0,0,0,0,0,1 }, //A
>       { 0,1,0,0,0,1,0,1 }, //E
>       { 0,1,0,0,0,1,1,0 }, //F
>       { 0,1,0,0,0,1,1,1 }, //G
>       { 0,1,0,0,1,0,0,0 }, //H
>       { 0,1,0,0,1,0,0,1 }, //I
>       { 0,1,0,0,1,0,1,0 }, //J
>       { 0,1,0,0,0,0,0,1 }, //A
>       { 0,1,0,0,1,0,1,1 }, //K
>       { 0,1,0,0,1,1,0,0 }, //L
>       { 0,1,0,0,1,1,0,1 }, //M
>       { 0,1,0,0,1,1,1,0 }, //N
>       { 0,1,0,0,1,1,1,1 } //O
>   };
>
> // just after SpatialPooler sp initialized.
> // every column's Potential and Permanence
> column  0: 0 0 1 1 0 1 1 0   0.00 0.00 0.09 0.08 0.00 0.00 0.09 0.00
> column  1: 1 0 1 0 1 1 0 0   0.34 0.00 0.16 0.00 0.95 0.53 0.00 0.00
> column  2: 0 0 1 1 0 1 0 1   0.00 0.00 0.48 0.08 0.00 0.44 0.00 0.43
> column  3: 0 0 0 1 0 1 1 1   0.00 0.00 0.00 0.75 0.00 0.60 0.65 0.96
> column  4: 0 1 1 1 0 1 0 0   0.00 0.10 0.03 0.07 0.00 0.10 0.00 0.00
> column  5: 0 0 1 1 1 0 0 1   0.00 0.00 0.88 0.36 0.07 0.00 0.00 0.00
> column  6: 1 1 0 0 1 0 0 1   0.04 0.99 0.00 0.00 0.11 0.00 0.00 0.08
> column  7: 1 1 0 1 0 0 1 0   0.69 0.64 0.00 0.04 0.00 0.00 0.48 0.00
> column  8: 1 0 1 0 0 1 0 1   0.79 0.00 0.78 0.00 0.00 0.60 0.00 0.45
> column  9: 0 0 1 0 0 1 1 1   0.00 0.00 0.06 0.00 0.00 0.05 0.06 0.04
> column 10: 1 1 1 0 0 0 1 0   0.68 0.94 0.09 0.00 0.00 0.00 0.50 0.00
> column 11: 1 1 1 0 0 1 0 0   0.92 0.05 0.00 0.00 0.00 0.05 0.00 0.00
> column 12: 1 0 0 1 1 1 0 0   0.07 0.00 0.00 0.55 0.00 0.75 0.00 0.00
> column 13: 0 1 1 0 0 0 1 1   0.00 0.90 0.03 0.00 0.00 0.00 0.00 0.54
> column 14: 0 0 1 0 0 1 1 1   0.00 0.00 0.08 0.00 0.00 0.90 0.00 0.03
> column 15: 1 1 1 0 0 0 0 1   0.36 0.00 0.84 0.00 0.00 0.00 0.00 0.09
> column 16: 0 1 0 0 1 1 1 0   0.00 0.69 0.00 0.00 0.88 0.25 0.41 0.00
> column 17: 1 0 1 0 0 1 0 1   0.05 0.00 0.06 0.00 0.00 0.08 0.00 0.00
> column 18: 0 1 0 0 1 1 0 1   0.00 0.06 0.00 0.00 0.07 0.06 0.00 0.00
> column 19: 0 1 0 0 1 1 1 0   0.00 0.04 0.00 0.00 0.74 0.05 0.06 0.00
>
> // the input and the active columns. this input is A's ascii code.
> input  0: 0 1 0 0 0 0 0 1
> column 10: 0.68 0.99 0.09 0.00 0.00 0.00 0.49 0.00
> column 13: 0.00 0.95 0.00 0.00 0.00 0.00 0.00 0.59
> column 16: 0.00 0.74 0.00 0.00 0.87 0.24 0.41 0.00
>
> input  1: 0 1 0 0 0 0 0 1
> column 10: 0.67 1.00 0.08 0.00 0.00 0.00 0.48 0.00
> column 13: 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.64
> column 16: 0.00 0.79 0.00 0.00 0.86 0.23 0.40 0.00
>
> input  2: 0 1 0 0 0 0 0 1
> column 10: 0.66 1.00 0.07 0.00 0.00 0.00 0.48 0.00
> column 13: 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.69
> column 16: 0.00 0.84 0.00 0.00 0.85 0.22 0.39 0.00
>
> input  3: 0 1 0 0 0 0 0 1
> column 10: 0.65 1.00 0.06 0.00 0.00 0.00 0.47 0.00
> column 13: 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.74
> column 16: 0.00 0.89 0.00 0.00 0.84 0.22 0.38 0.00
>
> input  4: 0 1 0 0 0 0 0 1
> column 10: 0.64 1.00 0.05 0.00 0.00 0.00 0.46 0.00
> column 13: 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.79
> column 16: 0.00 0.94 0.00 0.00 0.84 0.21 0.37 0.00
>
> input  5: 0 1 0 0 0 0 0 1
> column 10: 0.64 1.00 0.05 0.00 0.00 0.00 0.45 0.00
> column 13: 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.84
> column 16: 0.00 0.99 0.00 0.00 0.83 0.20 0.37 0.00
>
> input  6: 0 1 0 0 0 0 0 1
> column 10: 0.63 1.00 0.04 0.00 0.00 0.00 0.44 0.00
> column 13: 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.89
> column 16: 0.00 1.00 0.00 0.00 0.82 0.19 0.36 0.00
>
> input  7: 0 1 0 0 0 0 0 1
> column 10: 0.62 1.00 0.03 0.00 0.00 0.00 0.44 0.00
> column 13: 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.94
> column 16: 0.00 1.00 0.00 0.00 0.81 0.18 0.35 0.00
>
> input  8: 0 1 0 0 0 0 0 1
> column 10: 0.61 1.00 0.00 0.00 0.00 0.00 0.43 0.00
> column 13: 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.99
> column 16: 0.00 1.00 0.00 0.00 0.80 0.18 0.34 0.00
>
> input  9: 0 1 0 0 0 0 0 1
> column 10: 0.60 1.00 0.00 0.00 0.00 0.00 0.42 0.00
> column 13: 0.00 1.00 0.00 0.00 0.00 0.00 0.00 1.00
> column 16: 0.00 1.00 0.00 0.00 0.80 0.17 0.33 0.00
>
> // now the 'O', you can see diffrent active columns, that's good.
> input 10: 0 1 0 0 1 1 1 1
> column  3: 0.00 0.00 0.00 0.74 0.00 0.65 0.70 1.00
> column 13: 0.00 1.00 0.00 0.00 0.00 0.00 0.05 1.00
> column 16: 0.00 1.00 0.00 0.00 0.85 0.22 0.38 0.00
>
> input 11: 0 1 0 0 1 1 1 1
> column  3: 0.00 0.00 0.00 0.74 0.00 0.70 0.75 1.00
> column 13: 0.00 1.00 0.00 0.00 0.00 0.00 0.10 1.00
> column 16: 0.00 1.00 0.00 0.00 0.90 0.27 0.43 0.00
>
> input 12: 0 1 0 0 1 1 1 1
> column  3: 0.00 0.00 0.00 0.73 0.00 0.75 0.80 1.00
> column 13: 0.00 1.00 0.00 0.00 0.00 0.00 0.15 1.00
> column 16: 0.00 1.00 0.00 0.00 0.95 0.32 0.48 0.00
>
> input 13: 0 1 0 0 1 1 1 1
> column  3: 0.00 0.00 0.00 0.72 0.00 0.80 0.85 1.00
> column 13: 0.00 1.00 0.00 0.00 0.00 0.00 0.20 1.00
> column 16: 0.00 1.00 0.00 0.00 1.00 0.37 0.53 0.00
>
> input 14: 0 1 0 0 1 1 1 1
> column  3: 0.00 0.00 0.00 0.71 0.00 0.85 0.90 1.00
> column 13: 0.00 1.00 0.00 0.00 0.00 0.00 0.25 1.00
> column 16: 0.00 1.00 0.00 0.00 1.00 0.42 0.58 0.00
>
> input 15: 0 1 0 0 1 1 1 1
> column  3: 0.00 0.00 0.00 0.70 0.00 0.90 0.95 1.00
> column 13: 0.00 1.00 0.00 0.00 0.00 0.00 0.30 1.00
> column 16: 0.00 1.00 0.00 0.00 1.00 0.47 0.63 0.00
>
> input 16: 0 1 0 0 1 1 1 1
> column  3: 0.00 0.00 0.00 0.70 0.00 0.95 1.00 1.00
> column 13: 0.00 1.00 0.00 0.00 0.00 0.00 0.35 1.00
> column 16: 0.00 1.00 0.00 0.00 1.00 0.52 0.68 0.00
>
> // !!!
> // problem 1: the active columns of input 'K', is {10, 13, 16}. it is same
> as the active columns of input 'A'.
> input 17: 0 1 0 0 1 0 1 1
> column 10: 0.60 1.00 0.00 0.00 0.00 0.00 0.47 0.00
> column 13: 0.00 1.00 0.00 0.00 0.00 0.00 0.40 1.00
> column 16: 0.00 1.00 0.00 0.00 1.00 0.51 0.73 0.00
>
> input 18: 0 1 0 0 1 0 1 1
> column 10: 0.59 1.00 0.00 0.00 0.00 0.00 0.52 0.00
> column 13: 0.00 1.00 0.00 0.00 0.00 0.00 0.45 1.00
> column 16: 0.00 1.00 0.00 0.00 1.00 0.50 0.78 0.00
>
> input 19: 0 1 0 0 1 0 1 1
> column 10: 0.58 1.00 0.00 0.00 0.00 0.00 0.57 0.00
> column 13: 0.00 1.00 0.00 0.00 0.00 0.00 0.50 1.00
> column 16: 0.00 1.00 0.00 0.00 1.00 0.49 0.83 0.00
>
> input 20: 0 1 0 0 1 0 1 1
> column 10: 0.57 1.00 0.00 0.00 0.00 0.00 0.62 0.00
> column 13: 0.00 1.00 0.00 0.00 0.00 0.00 0.55 1.00
> column 16: 0.00 1.00 0.00 0.00 1.00 0.49 0.88 0.00
>
> input 21: 0 1 0 0 1 0 1 1
> column 10: 0.56 1.00 0.00 0.00 0.00 0.00 0.67 0.00
> column 13: 0.00 1.00 0.00 0.00 0.00 0.00 0.60 1.00
> column 16: 0.00 1.00 0.00 0.00 1.00 0.48 0.93 0.00
>
> input 22: 0 1 0 0 1 0 1 1
> column 10: 0.56 1.00 0.00 0.00 0.00 0.00 0.72 0.00
> column 13: 0.00 1.00 0.00 0.00 0.00 0.00 0.65 1.00
> column 16: 0.00 1.00 0.00 0.00 1.00 0.47 0.98 0.00
>
> input 23: 0 1 0 0 0 0 1 0
> column 10: 0.55 1.00 0.00 0.00 0.00 0.00 0.77 0.00
> column 13: 0.00 1.00 0.00 0.00 0.00 0.00 0.70 0.99
> column 16: 0.00 1.00 0.00 0.00 0.99 0.46 1.00 0.00
>
> input 24: 0 1 0 0 0 0 1 1
> column 10: 0.54 1.00 0.00 0.00 0.00 0.00 0.82 0.00
> column 13: 0.00 1.00 0.00 0.00 0.00 0.00 0.75 1.00
> column 16: 0.00 1.00 0.00 0.00 0.98 0.45 1.00 0.00
>
> input 25: 0 1 0 0 0 1 0 0
> column 13: 0.00 1.00 0.00 0.00 0.00 0.00 0.74 0.99
> column 14: 0.00 0.00 0.07 0.00 0.00 0.95 0.00 0.00
> column 16: 0.00 1.00 0.00 0.00 0.98 0.50 0.99 0.00
>
> input 26: 0 1 0 0 0 0 0 1
> column 10: 0.53 1.00 0.00 0.00 0.00 0.00 0.81 0.00
> column 13: 0.00 1.00 0.00 0.00 0.00 0.00 0.73 1.00
> column 16: 0.00 1.00 0.00 0.00 0.97 0.50 0.98 0.00
>
> input 27: 0 1 0 0 0 1 0 1
> column  8: 0.78 0.00 0.77 0.00 0.00 0.65 0.00 0.50
> column 13: 0.00 1.00 0.00 0.00 0.00 0.00 0.73 1.00
> column 16: 0.00 1.00 0.00 0.00 0.96 0.55 0.98 0.00
>
> input 28: 0 1 0 0 0 1 1 0
> column 10: 0.52 1.00 0.00 0.00 0.00 0.00 0.86 0.00
> column 13: 0.00 1.00 0.00 0.00 0.00 0.00 0.78 0.99
> column 16: 0.00 1.00 0.00 0.00 0.95 0.60 1.00 0.00
>
> input 29: 0 1 0 0 0 1 1 1
> column  3: 0.00 0.00 0.00 0.69 0.00 1.00 1.00 1.00
> column 13: 0.00 1.00 0.00 0.00 0.00 0.00 0.83 1.00
> column 16: 0.00 1.00 0.00 0.00 0.94 0.65 1.00 0.00
>
> input 30: 0 1 0 0 1 0 0 0
> column  6: 0.04 1.00 0.00 0.00 0.16 0.00 0.00 0.07
> column 16: 0.00 1.00 0.00 0.00 0.99 0.64 0.99 0.00
> column 19: 0.00 0.09 0.00 0.00 0.79 0.04 0.05 0.00
>
> input 31: 0 1 0 0 1 0 0 1
> column  6: 0.03 1.00 0.00 0.00 0.21 0.00 0.00 0.12
> column 13: 0.00 1.00 0.00 0.00 0.00 0.00 0.82 1.00
> column 16: 0.00 1.00 0.00 0.00 1.00 0.63 0.98 0.00
>
> input 32: 0 1 0 0 1 0 1 0
> column 10: 0.52 1.00 0.00 0.00 0.00 0.00 0.91 0.00
> column 13: 0.00 1.00 0.00 0.00 0.00 0.00 0.87 0.99
> column 16: 0.00 1.00 0.00 0.00 1.00 0.62 1.00 0.00
>
> // !!!
> // problem 2: the active columns of 'A' now is {6, 13, 16}. it originally
> is {10, 13, 16}.
> input 33: 0 1 0 0 0 0 0 1
> column  6: 0.00 1.00 0.00 0.00 0.20 0.00 0.00 0.17
> column 13: 0.00 1.00 0.00 0.00 0.00 0.00 0.86 1.00
> column 16: 0.00 1.00 0.00 0.00 0.99 0.61 0.99 0.00
>
> input 34: 0 1 0 0 1 0 1 1
> column  6: 0.00 1.00 0.00 0.00 0.25 0.00 0.00 0.22
> column 13: 0.00 1.00 0.00 0.00 0.00 0.00 0.91 1.00
> column 16: 0.00 1.00 0.00 0.00 1.00 0.61 1.00 0.00
>
> input 35: 0 1 0 0 1 1 0 0
> column  1: 0.33 0.00 0.15 0.00 1.00 0.58 0.00 0.00
> column  6: 0.00 1.00 0.00 0.00 0.30 0.00 0.00 0.21
> column 16: 0.00 1.00 0.00 0.00 1.00 0.66 0.99 0.00
>
> input 36: 0 1 0 0 1 1 0 1
> column  6: 0.00 1.00 0.00 0.00 0.35 0.00 0.00 0.26
> column 13: 0.00 1.00 0.00 0.00 0.00 0.00 0.90 1.00
> column 16: 0.00 1.00 0.00 0.00 1.00 0.71 0.98 0.00
>
> input 37: 0 1 0 0 1 1 1 0
> column 10: 0.51 1.00 0.00 0.00 0.00 0.00 0.96 0.00
> column 13: 0.00 1.00 0.00 0.00 0.00 0.00 0.95 0.99
> column 16: 0.00 1.00 0.00 0.00 1.00 0.76 1.00 0.00
>
> input 38: 0 1 0 0 1 1 1 1
> column  6: 0.00 1.00 0.00 0.00 0.40 0.00 0.00 0.31
> column 13: 0.00 1.00 0.00 0.00 0.00 0.00 1.00 1.00
> column 16: 0.00 1.00 0.00 0.00 1.00 0.81 1.00 0.00
>
> * end.
>
>
>
>
>

Reply via email to