NN.MDB
The Database that thinks
© 2007 Ben Margolis
How It Works
I
started with an excellent VB AI example project by
Takis Firipidis. It is a simple AI logic
gate, with two inputs and three neurons, but it contains a perfect example of
how to execute an activation function in VB.
After several day’s of reverse engineering, I converted his VB code to VBA,
replaced his references to memory variables with ADO calls to Access data
sources, and I built a database schema with three tables of Networks, Neurons
and Synapses to store the nets.
The system can store many Neural Networks in these three tables at once, and can
even share neurons between Networks creating multi-tiered and clustered
multi-network solutions. Furthermore, given that Access (or SQL) cans store
millions of rows of data, the system could theoretically handle networks of
massive size (although currently training is way too slow for that and the Network Diagram
it draws starts to become illegible with more than 100 neurons in a layer).
The main table of the system is the Table of Networks, (tblNets) each record
contains network architecture, names of data sources, and training history. The
Table of Neurons (nn1Neu) and the Table of Synapses (nn1Syn) are linked to
tblNets by Network ID (NetID) and to each other by Neural ID (nID).
Two main SQL queries (qryCurrNN and qryCurrNNSynLayer) identify the current NN
and activate the top and bottom halves of the MLP in sequence.
The original idea was to create a pure SQL solution. There were two SQL queries
for forward activation of the MLP and four more for back propagation. This was
way to slow. By version 2.0, I had replaced most of that with ADO calls in a
series of VBA subs. Its much faster, but I still use two queries for backprop.
Using it is pretty simple, tblNet contains text fields for data source names
that map to ANY Access data source, including local and linked Access tables,
remote SQL servers and ODBC sources. The Table of Neurons contains a similar
column that maps individual neurons to individual fields in these tables. (click
here for a walk-though)
The simplest way to implement NN.MDB is simply to link tables between your MSA
app and NN.MDB then open NN.MDB run it on the linked table, then go back to your
app and view the results.
Everything is native and completely internal to MS Access and requires no
outside APIs or external function calls at all. (Except for the TTS voice
add-on, which makes calls to Excel to activate the Windows TTS engine. Oh yes,
it talks.)
All in all, I was amazed at how little code it really is. The single module,
basNN1, prints out on five pages and contains all the code need to create the NN,
train it, test it, and run it. And even then some of its a little redundant.
|