-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
820 additions
and
1,833 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,180 +1,175 @@ | ||
// Copyright (c) 2020, The Emergent Authors. All rights reserved. | ||
// Copyright (c) 2024, The Emergent Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package main | ||
|
||
import "github.com/emer/axon/v2/axon" | ||
import ( | ||
"github.com/emer/axon/v2/axon" | ||
) | ||
|
||
// ParamConfig has config parameters related to sim params | ||
// EnvConfig has config params for environment. | ||
type EnvConfig struct { | ||
|
||
// Env parameters: can set any field/subfield on Env struct, | ||
// using standard TOML formatting. | ||
Env map[string]any | ||
|
||
// MinDiffPct is the minimum difference between item random patterns, | ||
// as a proportion (0-1) of total active | ||
MinDiffPct float32 `default:"0.5"` | ||
|
||
// DriftCtxt means use drifting context representations, | ||
// otherwise does bit flips from prototype. | ||
DriftCtxt bool | ||
|
||
// CtxtFlipPct is the proportion (0-1) of active bits to flip | ||
// for each context pattern, relative to a prototype, for non-drifting. | ||
CtxtFlipPct float32 `default:"0.25"` | ||
|
||
// DriftPct is percentage of active bits that drift, per step, for drifting context. | ||
DriftPct float32 `default:"0.1"` | ||
} | ||
|
||
// ParamConfig has config parameters related to sim params. | ||
type ParamConfig struct { | ||
|
||
// network parameters | ||
Network map[string]any | ||
// InToEc2PCon is percent connectivity from Input to EC2. | ||
InToEc2PCon float32 `default:"0.25"` | ||
|
||
// ECPctAct is percent activation in EC pool, used in patgen for input generation. | ||
ECPctAct float32 `default:"0.2"` | ||
|
||
// Extra Param Sheet name(s) to use (space separated if multiple) -- must be valid name as listed in compiled-in params or loaded params | ||
// Sheet is the extra params sheet name(s) to use (space separated | ||
// if multiple). Must be valid name as listed in compiled-in params | ||
// or loaded params. | ||
Sheet string | ||
|
||
// extra tag to add to file names and logs saved from this run | ||
// Tag is an extra tag to add to file names and logs saved from this run. | ||
Tag string | ||
|
||
// user note -- describe the run params etc -- like a git commit message for the run | ||
// Note is additional info to describe the run params etc, | ||
// like a git commit message for the run. | ||
Note string | ||
|
||
// Name of the JSON file to input saved parameters from. | ||
File string `nest:"+"` | ||
|
||
// Save a snapshot of all current param and config settings in a directory named params_<datestamp> (or _good if Good is true), then quit -- useful for comparing to later changes and seeing multiple views of current params | ||
// SaveAll will save a snapshot of all current param and config settings | ||
// in a directory named params_<datestamp> (or _good if Good is true), | ||
// then quit. Useful for comparing to later changes and seeing multiple | ||
// views of current params. | ||
SaveAll bool `nest:"+"` | ||
|
||
// for SaveAll, save to params_good for a known good params state. 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 time. | ||
// Good is for SaveAll, save to params_good for a known good params state. | ||
// 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:"+"` | ||
} | ||
|
||
// RunConfig has config parameters related to running the sim | ||
// RunConfig has config parameters related to running the sim. | ||
type RunConfig struct { | ||
|
||
// mem % correct level (proportion) above which training on current list stops (switch from AB to AC or stop on AC) | ||
StopMem float32 `default:"0.9"` | ||
|
||
// use the GPU for computation -- generally faster even for small models if NData ~16 | ||
// GPU uses the GPU for computation, generally faster than CPU even for | ||
// small models if NData ~16. | ||
GPU bool `default:"true"` | ||
|
||
// number of parallel threads for CPU computation -- 0 = use default | ||
// 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:"10" min:"1"` | ||
|
||
// NThreads is the number of parallel threads for CPU computation; | ||
// 0 = use default. | ||
NThreads int `default:"0"` | ||
|
||
// starting run number -- determines the random seed -- runs counts from there -- can do all runs in parallel by launching separate jobs with each run, runs = 1 | ||
// MemThr is the threshold on proportion on / off error to count item as remembered | ||
MemThr float64 `default:"0.34"` | ||
|
||
// StopMem is memory pct correct level (proportion) above which training | ||
// on current list stops (switch from AB to AC or stop on AC). | ||
StopMem float32 `default:"0.9"` | ||
|
||
// Run is the _starting_ run number, which determines the random seed. | ||
// NRuns counts up from there. Can do all runs in parallel by launching | ||
// separate jobs with each starting Run, NRuns = 1. | ||
Run int `default:"0"` | ||
|
||
// total number of runs to do when running Train | ||
// Runs is the total number of runs to do when running Train, starting from Run. | ||
Runs int `default:"5" min:"1"` | ||
|
||
// total number of epochs per run | ||
// Epochs is the total number of epochs per run. | ||
Epochs int `default:"100"` | ||
|
||
// total number of trials per epoch. Should be an even multiple of NData. | ||
NTrials int `default:"20"` | ||
// Trials is the total number of trials per epoch. | ||
// Should be an even multiple of NData. | ||
Trials int `default:"20"` | ||
|
||
// number of data-parallel items to process in parallel per trial -- works (and is significantly faster) for both CPU and GPU. Results in an effective mini-batch of learning. | ||
NData int `default:"10" min:"1"` | ||
// Cycles is the total number of cycles per trial: at least 200. | ||
Cycles int `default:"200"` | ||
|
||
// PlusCycles is the total number of plus-phase cycles per trial. For Cycles=300, use 100. | ||
PlusCycles int `default:"50"` | ||
|
||
// how often to run through all the test patterns, in terms of training epochs -- can use 0 or -1 for no testing | ||
TestInterval int `default:"1"` | ||
// 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"` | ||
} | ||
|
||
// LogConfig has config parameters related to logging data | ||
// LogConfig has config parameters related to logging data. | ||
type LogConfig struct { | ||
|
||
// if true, save final weights after each run | ||
// SaveWeights will save final weights after each run. | ||
SaveWeights bool | ||
|
||
// if true, save train epoch log to file, as .epc.tsv typically | ||
Epoch bool `default:"true" nest:"+"` | ||
|
||
// if true, save run log to file, as .run.tsv typically | ||
Run bool `default:"true" nest:"+"` | ||
|
||
// if true, save train trial log to file, as .trl.tsv typically. May be large. | ||
Trial bool `default:"false" nest:"+"` | ||
// Train has the list of Train mode levels to save log files for. | ||
Train []string `default:"['Run', 'Epoch']" nest:"+"` | ||
|
||
// if true, save testing epoch log to file, as .tst_epc.tsv typically. In general it is better to copy testing items over to the training epoch log and record there. | ||
TestEpoch bool `default:"false" nest:"+"` | ||
|
||
// if true, save testing trial log to file, as .tst_trl.tsv typically. May be large. | ||
TestTrial bool `default:"false" nest:"+"` | ||
|
||
// if true, save network activation etc data from testing trials, for later viewing in netview | ||
NetData bool | ||
} | ||
|
||
// PatConfig have the pattern parameters | ||
type PatConfig struct { | ||
|
||
// minimum difference between item random patterns, as a proportion (0-1) of total active | ||
MinDiffPct float32 | ||
|
||
// use drifting context representations -- otherwise does bit flips from prototype | ||
DriftCtxt bool | ||
|
||
// proportion (0-1) of active bits to flip for each context pattern, relative to a prototype, for non-drifting | ||
CtxtFlipPct float32 | ||
|
||
// percentage of active bits that drift, per step, for drifting context | ||
DriftPct float32 | ||
} | ||
|
||
func (pp *PatConfig) Defaults() { | ||
pp.MinDiffPct = 0.5 | ||
pp.CtxtFlipPct = .25 | ||
// Test has the list of Test mode levels to save log files for. | ||
Test []string `nest:"+"` | ||
} | ||
|
||
type ModConfig struct { | ||
|
||
// percent connectivity from Input to EC2 | ||
InToEc2PCon float32 | ||
|
||
// percent activation in EC pool, used in patgen for input generation | ||
// percent activation in EC pool, used in patgen for input generation | ||
ECPctAct float32 | ||
|
||
// memory threshold | ||
MemThr float64 | ||
} | ||
|
||
func (mod *ModConfig) Defaults() { | ||
// patgen | ||
mod.ECPctAct = 0.2 | ||
// Config has the overall Sim configuration options. | ||
type Config struct { | ||
|
||
// input to EC2 pcon | ||
mod.InToEc2PCon = 0.25 | ||
// Name is the short name of the sim. | ||
Name string `display:"-" default:"Hip"` | ||
|
||
// // theta EDL in CA1 | ||
// mod.ThetaLow = 0.9 // doesn't have strong effect at low NTrials but shouldn't go too low (e.g., 0.3) | ||
// mod.ThetaHigh = 1 | ||
// Title is the longer title of the sim. | ||
Title string `display:"-" default:"Axon hippocampus"` | ||
|
||
// // EDL in CA3 | ||
// mod.MossyDel = 4 | ||
// mod.MossyDelTest = 3 | ||
// URL is a link to the online README or other documentation for this sim. | ||
URL string `display:"-" default:"https://github.com/emer/axon/blob/main/examples/hip/README.md"` | ||
|
||
// memory threshold | ||
mod.MemThr = 0.34 | ||
} | ||
// Doc is brief documentation of the sim. | ||
Doc string `display:"-" default:"Simulates the hippocampus on basic AB-AC paired associates task."` | ||
|
||
// Config is a standard Sim config -- use as a starting point. | ||
type Config struct { | ||
|
||
// specify include files here, and after configuration, it contains list of include files added | ||
// Includes has a list of additional config files to include. | ||
// After configuration, it contains list of include files added. | ||
Includes []string | ||
|
||
// open the GUI -- does not automatically run -- if false, then runs automatically and quits | ||
// GUI means open the GUI. Otherwise it runs automatically and quits, | ||
// saving results to log files. | ||
GUI bool `default:"true"` | ||
|
||
// log debugging information | ||
// Debug reports debugging information. | ||
Debug bool | ||
|
||
// misc model parameters | ||
Mod ModConfig `display:"inline"` | ||
|
||
// Hippocampus sizing parameters | ||
Hip axon.HipConfig | ||
// Hip has hippocampus sizing parameters. | ||
Hip axon.HipConfig `display:"add-fields"` | ||
|
||
// parameters for the input patterns | ||
Pat PatConfig | ||
// Env has environment configuration options. | ||
Env EnvConfig `display:"add-fields"` | ||
|
||
// parameter related configuration options | ||
// Params has parameter related configuration options. | ||
Params ParamConfig `display:"add-fields"` | ||
|
||
// sim running related configuration options | ||
// Run has sim running related configuration options. | ||
Run RunConfig `display:"add-fields"` | ||
|
||
// data logging related configuration options | ||
// Log has data logging related configuration options. | ||
Log LogConfig `display:"add-fields"` | ||
} | ||
|
||
func (cfg *Config) Defaults() { | ||
cfg.Mod.Defaults() | ||
cfg.Hip.Defaults() | ||
cfg.Pat.Defaults() | ||
} | ||
|
||
func (cfg *Config) IncludesPtr() *[]string { return &cfg.Includes } |
Oops, something went wrong.