Skip to content

Commit

Permalink
lvis runs and is at ~200 msec per trial on the macbook GPU ndata=4, w…
Browse files Browse the repository at this point in the history
…hich is 5 or more times faster than previous best-case synaptic calcium jobs using up to 16 MPI nodes.
  • Loading branch information
rcoreilly committed Jan 17, 2025
1 parent 85bebc0 commit 677118e
Show file tree
Hide file tree
Showing 15 changed files with 50,685 additions and 158 deletions.
3 changes: 3 additions & 0 deletions axon/path.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions axon/path.goal
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ func (pt *Path) Validate(logmsg bool) error {
// RecvSynIxs returns the receiving synapse indexes for given recv unit index
// within the receiving layer, to be iterated over for recv-based processing.
func (pt *Path) RecvSynIxs(ri uint32) []uint32 {
if int(ri) >= len(pt.RecvCon) {
return nil
}
rcon := pt.RecvCon[ri]
return pt.RecvSynIndex[rcon.Start : rcon.Start+rcon.N]
}
Expand Down
47 changes: 47 additions & 0 deletions sims/lvis/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# LVis CU3D100 TE16deg Axon

This is the "standard" version of the LVis model, implemented using the `axon` spiking activation algorithm, with the architecture tracing back to the `cemer` C++ versions that were originally developed (`lvis_te16deg.proj` and `lvis_fix8.proj`).

The `lvix_fix8.proj` version has "blob" color filters in addition to the monochrome gabor filters, and has the capacity to fixate on different regions in the image, but this was never fully utilized. This Go implementation has the blob color filters, but no specified fixation -- just random 2D planar transforms.

# Images: CU3D100

This [google drive folder](https://drive.google.com/drive/folders/13Mi9aUlF1A3sx3JaofX-qzKlxGoViT86?usp=sharing) has .png input files for use with this model.

By default the models looks for the images extracted from `CU3D_100_renders_lr20_u30_nb.tar.gz` in the `<repo>/sims/lvis_cu3d100_te16deg_axon/images/CU3D_100_renders_lr20_u30_nb/` folder. This contains 18,859 images of rendered 3D objects from 100 different object categories, with roughly 8-10 3D object instances per category.

See `Config.Env.Path` for path to use for finding these files -- typically make a symlink for `images` to point to a central location having these files.

There is also a larger collection of images: `CU3D_100_plus_renders.tar.gz` which has 30,240 rendered images from the same 100 3D object categories, with 14.45 average different instances per category. However, the additional instances were of lower quality overall and performance is generally slightly worse with this set.

The original reference for these images and the LVis model is:

O'Reilly, R.C., Wyatte, D., Herd, S., Mingus, B. & Jilk, D.J. (2013). Recurrent Processing during Object Recognition. *Frontiers in Psychology, 4,* 124. [PDF](https://ccnlab.org/papers/OReillyWyatteHerdEtAl13.pdf) | [URL](http://www.ncbi.nlm.nih.gov/pubmed/23554596)

The image specs are: 320x320 color images. 100 object classes, 20 images per exemplar. Rendered with 40° depth rotation about y-axis (plus horizontal flip), 20° tilt rotation about x-axis, 80° overhead lighting rotation.

The `ImagesEnv` environment in `images_env.go` adds in-plane affine transformations (translation, scale, rotation) (now known as "data augmentation"), with the standard case being scaling in the range .7 - 1.2, rotation +/- 16 degrees, and translation using a uniform distribution of 30% of the half-width of the image, where 100% would move something in the center to be centered on the edge. 30% is about the maximum amount of translation that does not result in significant amounts of the image being off the edge.

# Benchmarking

See [bench](bench.md) for full info.

# Building

To build and link against MPI:
```bash
go build -v -mod=mod -tags mpi
```
Without the tag all the MPI calls are replaced with stubs that don't do anything.

To run with MPI (e.g.):
```bash
mpirun -np 4 ./lvis_cu3d100_te16deg_axon -no-gui -mpi
```

# TODO:

* no f8
* no cross between f8, f16
* no te

41 changes: 16 additions & 25 deletions sims/lvis/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

package main

import "github.com/emer/emergent/v2/paths"

// EnvConfig has config params for environment
// note: only adding fields for key Env params that matter for both Network and Env
// other params are set via the Env map data mechanism.
Expand All @@ -14,6 +12,15 @@ type EnvConfig struct { //types:add
// env parameters -- can set any field/subfield on Env struct, using standard TOML formatting
Env map[string]any

// other option for below: Path = "images/CU3D_100_plus_renders", ImageFile = "cu3d100plus"
// works somewhat worse

// Path is the file path for the images. Create a symbolic link in sim dir for images.
Path string `default:"images/CU3D_100_renders_lr20_u30_nb"`

// ImageFile is the prefix for config files with lists of categories and images.
ImageFile string `default:"cu3d100old"`

// number of units per localist output unit
NOutPer int `default:"5"`

Expand Down Expand Up @@ -54,21 +61,6 @@ type ParamConfig struct {
// This can be done prior to making a new release after all tests are passing.
// Add results to git to provide a full diff record of all params over level.
Good bool `nest:"+"`

// pathway from V1 to V4 which is tiled 4x4 skip 2 with topo scale values.
V1V4Path *paths.PoolTile `nest:"+"`
}

func (cfg *ParamConfig) Defaults() {
cfg.V1V4Path = paths.NewPoolTile()
cfg.V1V4Path.Size.Set(4, 4)
cfg.V1V4Path.Skip.Set(2, 2)
cfg.V1V4Path.Start.Set(-1, -1)
cfg.V1V4Path.TopoRange.Min = 0.8 // note: none of these make a very big diff
// but using a symmetric scale range .8 - 1.2 seems like it might be good -- otherwise
// weights are systematicaly smaller.
// ss.V1V4Path.GaussFull.DefNoWrap()
// ss.V1V4Path.GaussInPool.DefNoWrap()
}

// RunConfig has config parameters related to running the sim.
Expand All @@ -93,7 +85,7 @@ type RunConfig struct {
// NData is the number of data-parallel items to process in parallel per trial.
// Is significantly faster for both CPU and GPU. Results in an effective
// mini-batch of learning.
NData int `default:"16" min:"1"`
NData int `default:"4" min:"1"`

// NThreads is the number of parallel threads for CPU computation;
// 0 = use default.
Expand All @@ -105,14 +97,14 @@ type RunConfig struct {
Run int `default:"0" flag:"run"`

// Runs is the total number of runs to do when running Train, starting from Run.
Runs int `default:"5" min:"1"`
Runs int `default:"1" min:"1"`

// Epochs is the total number of epochs per run.
Epochs int `default:"200"`
Epochs int `default:"500"`

// Trials is the total number of trials per epoch.
// Should be an even multiple of NData.
Trials int `default:"128"`
Trials int `default:"512"`

// Cycles is the total number of cycles per trial: at least 200.
Cycles int `default:"200"`
Expand All @@ -128,7 +120,7 @@ type RunConfig struct {

// TestInterval is how often (in epochs) to run through all the test patterns,
// in terms of training epochs. Can use 0 or -1 for no testing.
TestInterval int `default:"5"`
TestInterval int `default:"20"`

// PCAInterval is how often (in epochs) to compute PCA on hidden
// representations to measure variance.
Expand Down Expand Up @@ -193,8 +185,7 @@ type Config struct {
Log LogConfig `display:"add-fields"`
}

func (cfg *Config) IncludesPtr() *[]string { return &cfg.Includes }

func (cfg *Config) Defaults() {
cfg.Params.Defaults()
}

func (cfg *Config) IncludesPtr() *[]string { return &cfg.Includes }
102 changes: 102 additions & 0 deletions sims/lvis/cu3d100old_cats.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
[
"airplane",
"anchor",
"autogun",
"banana",
"basinsink",
"bed",
"bicycle",
"blade",
"blender",
"blimp",
"boombox",
"bottle",
"bow",
"candle",
"car",
"chair",
"chandelier",
"chessboard",
"chesspiece",
"compactcamera",
"cross",
"cup",
"dice",
"domestictree",
"donut",
"doorhandle",
"doorknob",
"dresser",
"drums",
"dutchwindmill",
"elephant",
"fan",
"fireplace",
"fish",
"flashlight",
"fryingpan",
"globe",
"grenade",
"guitar",
"hammer",
"handgun",
"hat",
"headphones",
"heavycannon",
"helicopter",
"hotairballoon",
"hourglass",
"hydrant",
"key",
"ladder",
"laptop",
"layercake",
"lightcannon",
"lock",
"locomotive",
"longgun",
"mailbox",
"microwave",
"motorcycle",
"pckeyboard",
"pedestalsink",
"person",
"piano",
"plant",
"plate",
"pliers",
"propellor",
"remote",
"rolltopdesk",
"sailboat",
"scissors",
"screwdriver",
"sectionalcouch",
"simpledesk",
"skateboard",
"skull",
"slrcamera",
"speaker",
"spotlightlamp",
"stapler",
"submarine",
"synthesizer",
"tablelamp",
"tank",
"telephone",
"television",
"toaster",
"toilet",
"trafficcone",
"trafficlight",
"trex",
"trombone",
"tropicaltree",
"trumpet",
"turntable",
"umbrella",
"wallclock",
"warningsign",
"wrench",
"yacht"
]
Loading

0 comments on commit 677118e

Please sign in to comment.