neural simulation language nsl

35
1 Brain Theory and Artificial Intelligence, USC, Fall 2001. Neural Simulation Language NSL

Upload: slade

Post on 22-Feb-2016

63 views

Category:

Documents


0 download

DESCRIPTION

Neural Simulation Language NSL. Overview. Introduction NSLM Example (Max Selector) NSLS Downloading and installing NSL. Introduction. NSL is a platform for Building neural architectures (modeling) NSLM NSLJ & NSLC Executing them (simulation). NSLS - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Neural Simulation Language NSL

1CS564 - Brain Theory and Artificial Intelligence, USC, Fall 2001.

Neural Simulation LanguageNSL

Page 2: Neural Simulation Language NSL

2CS564 - Brain Theory and Artificial Intelligence, USC, Fall 2001.

Overview

IntroductionNSLMExample (Max Selector)NSLSDownloading and installing NSL

Page 3: Neural Simulation Language NSL

3CS564 - Brain Theory and Artificial Intelligence, USC, Fall 2001.

Introduction

NSL is a platform for

Building neural architectures (modeling) NSLM

NSLJ & NSLCExecuting them (simulation).

NSLS

NSL provides tools for modeling complex neural systems - especially (but not only) when the neurons are modeled as leaky integrator neurons.

Page 4: Neural Simulation Language NSL

4CS564 - Brain Theory and Artificial Intelligence, USC, Fall 2001.

Methodology

The general methodology for making a complex neural model of brain function is to combine different modules corresponding to different brain regions.

To model a particular brain region, we divide it anatomically or physiologically into different neural arrays.

Each brain region is then modeled as a set of neuron arrays, where each neuron is described for example by the leaky integrator, a single-compartment model of membrane potential and firing rate.

Page 5: Neural Simulation Language NSL

5CS564 - Brain Theory and Artificial Intelligence, USC, Fall 2001.

Levels of abstraction

A complete model in NSL requires the following components:

•a set of modules defining the entire model

•neurons comprised in each neural module

•neural interconnections

•neural dynamics

•numerical methods to solve the differential equations.

Page 6: Neural Simulation Language NSL

6CS564 - Brain Theory and Artificial Intelligence, USC, Fall 2001.

Example of modules

Bischoff's Model

Retina

Basal Ganglia

Hoff - Arbib

Thalamus

VLO

Cortex

SMA

MC

PreSMA SMAProper

Inh Mvt

Putamen

GPi/SNr

SNc

GPe

STN

Page 7: Neural Simulation Language NSL

7CS564 - Brain Theory and Artificial Intelligence, USC, Fall 2001.

Leaky integrator

Page 8: Neural Simulation Language NSL

8CS564 - Brain Theory and Artificial Intelligence, USC, Fall 2001.

Simulation

1

2

3 4

5

6

7

Page 9: Neural Simulation Language NSL

9CS564 - Brain Theory and Artificial Intelligence, USC, Fall 2001.

Simulation Methods

initSysinitModule

makeConn … (simulation steps)endModule

endSys

Page 10: Neural Simulation Language NSL

10CS564 - Brain Theory and Artificial Intelligence, USC, Fall 2001.

Simulation Methods

initTrainEpoch

initTrain

simTrain

endTrain

endTrainEpoch

initRunEpoch

initRun

simRun

endRun

endRunEpoch

train

run

trainAndRunAlldoTrainEpochTimes

doRunEpochTimes

Page 11: Neural Simulation Language NSL

11CS564 - Brain Theory and Artificial Intelligence, USC, Fall 2001.

Model Structures

Model Highest level

Modules NeuralNetworks

InModulesOutModules

Graphic InterfacesMotorModules

Robotics

NslClass Libraries New Canvases New NSLS Commands

Page 12: Neural Simulation Language NSL

12CS564 - Brain Theory and Artificial Intelligence, USC, Fall 2001.

NSLM Types

Primitive typesintfloatdoublebooleanchar

NslData types (0, 1, 2, 3, 4)NslIntNslFloatNslDoubleNslBooleanNslString (0)

Could be public, private or protected.

NslPort types (0, 1, 2, 3, 4)NslDinIntNslDinFloatNslDinDoubleNslDinBooleanNslDinString (0)NslDoutIntNslDoutFloatNslDoutDoubleNslDoutBooleanNslDoutString (0)

Ports must be public

Page 13: Neural Simulation Language NSL

13CS564 - Brain Theory and Artificial Intelligence, USC, Fall 2001.

Max Selector Model

The details of this model can be found in section 4.4 of TMB2.

The model uses competition mechanisms to obtain, in many cases, a single winner in the network where the input signal with the greatest strength is propagated along to the output of the network.

Page 14: Neural Simulation Language NSL

14CS564 - Brain Theory and Artificial Intelligence, USC, Fall 2001.

Max Selector Model (2)

Page 15: Neural Simulation Language NSL

15CS564 - Brain Theory and Artificial Intelligence, USC, Fall 2001.

Max Selector Model (3)

MaxSelectorModel

MaxSelectorStimulus Output

ULayer

VLayer

Page 16: Neural Simulation Language NSL

16CS564 - Brain Theory and Artificial Intelligence, USC, Fall 2001.

MaxSelectorModelnslImport nslAllImports;

nslImport MaxSelectorStimulus;nslImport MaxSelector;nslImport MaxSelectorOutput;

nslModel MaxSelectorModel() {

nslConst int size = 10;

private MaxSelectorStimulus stimulus(size); private MaxSelector maxselector(size); private MaxSelectorOutput output(size);

public void initSys() {system.setRunEndTime(10.0);system.nslSetRunDelta(0.1);

}

public void makeConn() { nslConnect(stimulus.s_out, maxselector.in);nslConnect(stimulus.s_out, output.s_out);nslConnect(maxselector.out, output.uf);

}}

Page 17: Neural Simulation Language NSL

17CS564 - Brain Theory and Artificial Intelligence, USC, Fall 2001.

MaxSelectorStimulus

nslImport nslAllImports;

nslModule MaxSelectorStimulus(int size) {

public NslDoutDouble1 s_out(size);

public void initRun() {s_out=0;s_out[1]=0.5;s_out[3]=1.0;

}}

Page 18: Neural Simulation Language NSL

18CS564 - Brain Theory and Artificial Intelligence, USC, Fall 2001.

MaxSelectorOutput

nslImport nslAllImports;

nslOutModule MaxSelectorOutput(int size) { public NslDinDouble1 s_out(size); public NslDinDouble1 uf(size); private NslDouble1 up(size); private boolean worked= false; public void initModule() {

up.nslSetAccess('W'); nslAddAreaCanvas(s_out,0,1); nslAddTemporalCanvas(up,-2.5,2.5); nslAddAreaCanvas(uf,0,1); }

public void simRun() { worked=nslSetValue(up,"maxSelectorModel.maxselector.u1.up"); }}

Page 19: Neural Simulation Language NSL

19CS564 - Brain Theory and Artificial Intelligence, USC, Fall 2001.

MaxSelector

nslImport nslAllImports;

nslImport Ulayer;nslImport Vlayer;

nslModule MaxSelector(int size) {

public NslDinDouble1 in(size); public NslDoutDouble1 out(size);

private Ulayer u1(size); private Vlayer v1();

public void makeConn() {nslRelabel(this.in, u1.s_in);nslConnect(u1.uf, v1.u_in);nslConnect(v1.vf, u1.v_in);nslRelabel(u1.uf, this.out);

}}

Page 20: Neural Simulation Language NSL

20CS564 - Brain Theory and Artificial Intelligence, USC, Fall 2001.

ULayer

nslImport nslAllImports;

nslModule Ulayer(int size) { //inports public NslDinDouble1 s_in(); public NslDinDouble0 v_in(); //outports public NslDoutDouble1 uf(size); //variables private NslDouble1 up(size); private NslDouble0 w1();

private NslDouble0 w2(); private NslDouble0 h1(); private NslDouble0 k(); private double tau;

Page 21: Neural Simulation Language NSL

21CS564 - Brain Theory and Artificial Intelligence, USC, Fall 2001.

Ulayer(2)

public void initRun(){

uf = 0;up = 0;tau = 1.0;w1= 1.0;w2= 1.0;h1= 0.1;k= 0.1;

}

public void simRun(){//compute : up=up+((timestep/tu)*du/dt)up = nslDiff(up, tau, -up + w1*uf-w2*v_in - h1 + s_in);uf = nslStep(up,k.get(),0,1.0);

}}

Page 22: Neural Simulation Language NSL

22CS564 - Brain Theory and Artificial Intelligence, USC, Fall 2001.

VLayer

nslImport nslAllImports;

nslModule Vlayer() {

// ports public NslDinDouble1 u_in();

// output port public NslDoutDouble0 vf(); // variables private NslDouble0 vp(); // neuron potential private NslDouble0 h2(); private double tau; // time constant

Page 23: Neural Simulation Language NSL

23CS564 - Brain Theory and Artificial Intelligence, USC, Fall 2001.

Vlayer (2)

public void initRun() {vf=0;vp=0;tau=1.0;h2 = 0.5;

}

public void simRun() {// vp=vp+((timestep/tv)*dv/dt)vp = nslDiff(vp, tau, -vp + nslSum(u_in) -h2);vf = nslRamp(vp);

}}

Page 24: Neural Simulation Language NSL

24CS564 - Brain Theory and Artificial Intelligence, USC, Fall 2001.

Compilation

One model/module per fileThe file extension must be .modWe recommend to clean the model directory before compiling with the nslclean command

To compile the model you just have to execute the following command: nslc modelName

Where modelName is the Name of the file that contains the model structure.

For this example we should write: nslc MaxSelectorModelNote that we didn’t write the file extension at the end of the name.

Mod File Nlx File Java File Class File

Page 25: Neural Simulation Language NSL

25CS564 - Brain Theory and Artificial Intelligence, USC, Fall 2001.

Execution

To simulate your model you have to use the nsl command.

For this example you should write: nsl MaxSelectorModel

Two running modesText (-nodisplay)Graphic interface (default)

To redirect the standard output (-stdout console)To redirect the standard error (-stderr console)

Page 26: Neural Simulation Language NSL

26CS564 - Brain Theory and Artificial Intelligence, USC, Fall 2001.

Interface

Page 27: Neural Simulation Language NSL

27CS564 - Brain Theory and Artificial Intelligence, USC, Fall 2001.

Interface (2)

Page 28: Neural Simulation Language NSL

28CS564 - Brain Theory and Artificial Intelligence, USC, Fall 2001.

NSLS

To avoid re-compiling every time you modify your model parameters we provide the NSL script language known as NSLS which also provides a dynamic user control environment.

NSLS provides the following functionality:NSL model parameter assignmentNSL input specificationNSL simulation controlNSL file controlNSL graphics control

NSLS is an extension of the well know TCL scripting language, thus providing NSL and TCL functionality.

Page 29: Neural Simulation Language NSL

29CS564 - Brain Theory and Artificial Intelligence, USC, Fall 2001.

NSLS (2)

NSL command syntax: nsl subcommand [options]

Important NSL commands:nsl source fileName

(i.e. nsl source hopfield.nsls)nsl set variable value

(i.e. nsl set maxSelectorModel.stimulus.s_out {1 0 0.5})nsl get variable

(i.e. nsl get maxSelectorModel.stimulus.s_out)nsl runnsl train…nsl exit

Page 30: Neural Simulation Language NSL

30CS564 - Brain Theory and Artificial Intelligence, USC, Fall 2001.

NSLS example## Hopfield Network#

set A {}set B {}set C {}set D {}

proc memorize { x } {

puts "Memorizing $x" nsl set hopfield.inModule.input $xnsl train

}

proc test { x d } {

nsl set hopfield.dis $d nsl set hopfield.inModule.input $xnsl run

}

Page 31: Neural Simulation Language NSL

31CS564 - Brain Theory and Artificial Intelligence, USC, Fall 2001.

NSLS example (2)

proc initData {} {

global A B C D

set A { { -1 -1 1 1 -1 -1 }

{ -1 1 -1 -1 1 -1 } { -1 1 1 1 1 -1 } { -1 1 1 1 1 -1 }{ -1 1 -1 -1 1 -1 }{ -1 1 -1 -1 1 -1 }

} set B {

{ 1 1 -1 -1 -1 -1 }{ 1 1 -1 -1 -1 -1 } { 1 1 1 1 -1 -1 }{ 1 1 -1 -1 1 -1 } { 1 1 -1 -1 1 -1 } { 1 1 1 1 -1 -1 }

} … }

Page 32: Neural Simulation Language NSL

32CS564 - Brain Theory and Artificial Intelligence, USC, Fall 2001.

NSLS example (3)proc trainNetwork {} {global A B C D

memorize $Amemorize $Bmemorize $Cmemorize $D

}

proc NslMain {} {global A B C Dputs "Initializing"initDataputs "Training"trainNetworkputs "Testing"for { set i 10 } { $i<20 } { incr i } {

puts "Testing with distortion $i"test $A $i

}nsl set hopfield.dis 0

}

NslMain

Page 33: Neural Simulation Language NSL

33CS564 - Brain Theory and Artificial Intelligence, USC, Fall 2001.

Downloading NSL

First, you will need to install the latest Java SDK; get it directly from Sun at http://java.sun.com/j2se/1.3/.

Once this is setup and working, download the entire NSL tree from http://www-scf.usc.edu/~csci564/nsl.tar.gz

Extract the archive (Winzip or Pkzip).

Edit the file "NSL3_0_n\resume.bat" such that it matches your environment (you will have to specify the path where you installed Java, where you installed NSL, etc).

Execute the resume batch file before beginning a NSL session.

Page 34: Neural Simulation Language NSL

34CS564 - Brain Theory and Artificial Intelligence, USC, Fall 2001.

Downloading NSL (2)

@echo offecho Initializing NSL environment variables

set NSLJ_ROOT=C:\salvador\NSL3_0_nset JAVA_HOME=C:\jdk1.3set NSL_OS=windows

echo Updating path and classpath

set PATH=%JAVA_HOME%\bin;%NSLJ_ROOT%;%PATH%set CLASSPATH=%NSLJ_ROOT%;.;%NSLJ_ROOT%\nslj\src\main; %NSLJ_ROOT%\nslj\src\nsls\jacl; %NSLJ_ROOT%\nslj\src\nsls\tcljava

@echo on

Page 35: Neural Simulation Language NSL

35CS564 - Brain Theory and Artificial Intelligence, USC, Fall 2001.

References

A Weitzenfeld, MA Arbib and A Alexander, 2002, NSL Neural Simulation Language, MIT Press (in press)

An old version is at:http://www-hbp.usc.edu/_Documentation/NSL/Book/TOC.htm

For any NSL related questions and bug reports, please send me an email at [email protected]