Monday 12 September 2016

new function operator: bar-chart

Today I implemented a nice ASCII visualization for superpositions. The bar-chart operator. The intention is to make the results easier to read than the raw superpositions. Previously I used "table[ket,coeff]" to do something similar, but this makes a nice addition, and was only a few lines of code. Now, I need a nice worked example for this thing. How about the dog/cat example from the other day?

Load up some knowledge:
  context animal sound SDR's
  full |range> => range(|1>,|100>)
  encode |purring> => pick[5] full |range>
  encode |miaowing> => pick[5] full |range>
  encode |scratching at the door> => pick[5] full |range>
  encode |panting> => pick[5] full |range>
  encode |sniffing> => pick[5] full |range>

  sounds-it-makes |cat> => union[encode] (|purring> + |miaowing> + |scratching at the door>)
  sounds-it-makes |dog> => union[encode] (|panting> + |sniffing> + |scratching at the door>)
Now put the bar-chart[width] operator to use:
-- given scratching at the door predict dog or cat:
sa: bar-chart[50] similar-input[sounds-it-makes] encode |scratching at the door>
----------
dog : ||||||||||||||||||||||||||||||||||||||||||||||||||
cat : ||||||||||||||||||||||||||||||||||||||||||||||
----------
|bar chart>

-- given scratching and sniffing, predict dog or cat:
sa: bar-chart[50] similar-input[sounds-it-makes] encode (|scratching at the door> + |sniffing>)
----------
dog : ||||||||||||||||||||||||||||||||||||||||||||||||||
cat : |||||||||||||||||||||||
----------
|bar chart>

-- given panting, predict what other sounds are next:
sa: bar-chart[50] similar-input[encode] sounds-it-makes similar-input[sounds-it-makes] encode |panting>
----------
scratching at the door : ||||||||||||||||||||||||||||||||||||||||||||||||||
panting                : ||||||||||||||||||||||||||||||||||||||||||||||||||
sniffing               : ||||||||||||||||||||||||||||||||||||||||||||||||||
purring                : ||||||||||
----------
|bar chart>

-- given purring, predict what other sounds are next:
sa: bar-chart[50] similar-input[encode] sounds-it-makes similar-input[sounds-it-makes] encode |purring>
----------
scratching at the door : ||||||||||||||||||||||||||||||||||||||||||||||||||
purring                : ||||||||||||||||||||||||||||||||||||||||||
miaowing               : |||||||||||||||||||||||||||||||||||||||||
panting                : ||||||||
sniffing               : ||||||||
----------
|bar chart>

-- finally, given scratching, predict what other sounds are next:
sa: bar-chart[50] similar-input[encode] sounds-it-makes similar-input[sounds-it-makes] encode |scratching at the door>
----------
scratching at the door : ||||||||||||||||||||||||||||||||||||||||||||||||||
purring                : |||||||||||||||||||||||||||||
panting                : |||||||||||||||||||||||||
sniffing               : |||||||||||||||||||||||||
miaowing               : ||||||||||||||||||||||||
----------
|bar chart>
So with this, it is now much easier to understand the relative coefficients in our superpositions. And yeah, highlights that superpositions are pretty boring by themselves. Bar charts have been around for ever! The point of my project is that a lot of things become easy if we use superpositions as the fundamental data-type, especially anything trying to reproduce the behaviour of neurons. Of course, much more power is added by operators, and the operator composition rule that maps superpositions to superpositions.

The other comment I need to make is that of "background noise". eg, note that panting also predicts purring, and purring predicts panting and sniffing, though they do have lower coefficients. This might not initially make sense, given that cat noises should not predict dog noises, and vice versa. But I don't think this is a problem. The brain makes similar mistakes, and has a similar solution, drop/ignore everything below some threshold. In the above example, drop-below[0.15] tidies up our results nicely.

No comments:

Post a Comment