The Knowm API

To develop Machine Learning applications with the Knowm API you’ll need to understand the basics of AHaH computing and kT-RAM. The Knowm API is our programming interface with the digital emulator of Thermodynamic-RAM a.k.a kT-RAM. As we shall see, it allows us to create arbitrary instances of kT-RAM cores, with varying configurations, types, and initializations before testing our creations on real-world problems.

Like any tutorial, it helps when you can play with the technology as it is introduced, so we would recommend you sign up for the Knowm Developer Community and gain access to the full source code, working examples, in-depth tutorials and one-on-one help. Otherwise, feel free to follow along and learn.

What is kT-RAM

kT-RAM is the first neuro-memristive processor architecture we are emulating with the Knowm API and it’s where the magic of Machine Learning happens. The following is a crash course in kT-RAM which you can read before getting to the tutorials. If you’d like a more in-depth introduction I recommend the lesson series we have available to KDC members.

Kt-RAM is built on top of a the memristor circuit component, a circuit component that limits the flow of electrical current ( resistance ) with respect to the amount of charge that has previously flowed through it ( memory ). Hence its name, the memristor. You can read more about the memristor from our lesson on the kt-synapse

On kT-RAM these memristors are combined into differential pairs we call a synapse.

Knowm’s Synapse can be emulated with two memristors.

and these synaptic connections have been organized into a grid of cells, with a tree-like structure (H-Tree) connecting every cell to the AHaH Controller circuitry.

Thermodynamic-RAM

When a voltage is applied at leaves of this tree by an AHaH Controller, current is propagated up the H-Tree, through each activated cell, and back down the trunk, where the voltage is read via sensing circuitry. As energy flows through the activated synapses the conductivities of the individual synapses change, and hence, so will the voltage outputs seen at the base of the trunk on the kT-RAM chip.

By understanding how the memristor pairs adapt as we drive them (AHaH Computing), and by changing the drive patterns, we can accomplish a number of useful functions ranging from discrete logic to large-scale inference and pattern recognition. The goal of the KDC is to achieve primary performance parity with state-of-the-art machine learning methods, using kT-RAM or other AHaH Computing processors.

You can instantiate a kT-RAM object like this with the emulator with the following code:

Java

1

KTRAM21 kTRAM=newKTRAM(KTRAM21D.DigitalCoreType.BYTE)

The digital core types allow us to run efficient simulations with different degrees of accuracy, in this case the conductivity of each memristor in the differential-pair synapse is discretized into 256 levels or one byte of information. Via interchangeable cores, we can deploy efficient digital cores optimized for existing digital hardware, or more accurate physics-based models aimed at insuring circuit function. To read more about the core types here.

One of the advantages of the kT-RAM structure is that it can be easily demarcated into sub-trees of arbitrary sizes, so long as the synapses of each sub-tree are not activated together at the same time. In the picture above the tree’s labeled A, and B are examples of AHaH nodes of size 8 and 16. To create the AHaH nodes A and B seen above, we call the ktram.create method with a name, the number of synapse it has and the initial conductivity of those synapses. Other initial conductances are possible.

Java

1

2

3

kTRAM.create("A",8,SynapticInitType.HIGH);

kTRAM.create("B",16,SynapticInitType.HIGH);

The structure of the kT-RAM chip also allows us to easily reference the AHaH nodes’ synapses and apply voltages through them. For instance we could apply a voltage through the synapses highlighted in the picture below and then read the voltage at the root. In this case, these four synapses interact in deciding the voltage at the root while the other synapses remain floating.

kT-RAM Synaptic Activation

This brings up a fundamental aspect of AHaH computing: the spike code. We run the chip by selectively pulsing a set of synapses at one time and seeing how they interact. The available synapses on kT-RAM are called the spike channels, the active spikes make up the spike pattern, and the way we convert information into spikes before feeding it onto the chip is called a spike-encoding. Interestingly, this is exactly how our sensory nerves interface our brain, by spiking a set of wires that eventually fire up individual neurons.

Spike Encoding

With the emulator we can reference particular synapses by creating an array of integers which correspond to the individual synapses and then set them active on kT-RAM. For instance, we could spike all the eight synapses of the “A” and “B” AHaH nodes created earlier like this.

Java

1

2

3

4

5

6

7

int[]spikesA=newint[]{1,2,3,4,5,6,7,8}// All the A synapses

int[]spikesB=newint[]{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}// All the B synapses

kTRAM.setSpikes(“A”,spikesA);

kTRAM.setSpikes(“B”,spikesB);

Finally we can apply voltages through kT-RAM by selecting a previously instantiated AHaH node by name and executing one of 14 instructions from the kT-Core Instruction Set. To do this with the emulator we call an execute instruction. Each instruction will apply a voltage in a particular direction, e.g forward or reverse and this will effect how the conductivities of the synapses change and what outputs you read off. You can read more about the specifics here.

The following instruction pair FF-XX applies the forward voltages through the spiked synapses. We also read the voltage at the root by calling getY(). Note: this particular dual-instruction increases the conductivity of each spiked synapse a reverse operation would have done the opposite.

Java

1

2

3

floatyA=kTRAM.execute("A",Instruction.FF,Instruction.XX).getY();

floatyB=kTRAM.execute("B",Instruction.FF,Instruction.XX).getY();

At this point we’ve introduced, kT-RAM, how we interface with it, how we read the voltages it gives off, and how this effects its state. The next thing to do is build our simplest Machine Learning tool: a Linear Classifier.