env

package
v1.3.40 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 10, 2023 License: BSD-3-Clause Imports: 13 Imported by: 144

README

Docs: GoDoc

See Wiki Env page for detailed docs.

Package env defines the Env interface for environments, which determine the nature and sequence of States that can be used as inputs to a model and it can also accept Action responses from the model that affect how the environment evolves in the future.

By adhering to this interface, it is then easier to mix-and-match environments with models.

Env / Agent

The overall division of labor is that the model keeps track of the outer-most Run time-scale depending on its own parameters and learning trajectory and the environment is responsible for generating patterns for each run.

Multiple different environments will typically be used in a model, e.g., one for training and other(s) for testing. Even if these envs all share a common database of patterns, a different Env should be used for each case where different counters and sequences of events etc are presented, which keeps them from interfering with each other. Also, the etable.IdxView can be used to allow multiple different Env's to all present different indexed views into a shared common etable.Table (e.g., train / test splits). The basic FixedTable env implementation uses this.

Thus, the Env encapsulates all of the counter management logic for each aspect of model training and testing, so that the model itself just needs to manage which Env to use, when, and manage the connection of the Env States as inputs to the model, and vice-versa for Actions on the Env coming from the model.

With the newer looper framework, the counters are managed by looper independent of the env.

There is also an Envs map that provides a basic container for managing multiple Envs -- the key is typically an etime.Modes e.g., etime.Train or etime.Test.

The EnvDesc interface provides additional methods (originally included in Env) that describe the Counters, States, and Actions, of the Env. Each Element of the overall State allows annotation about the different elements of state that are available in general.

The Step should update all relevant state elements as appropriate, so these can be queried by the user. Particular paradigms of environments must establish naming conventions for these state elements which then allow the model to use the information appropriately -- the Env interface only provides the most basic framework for establishing these paradigms, and ultimately a given model will only work within a particular paradigm of environments following specific conventions.

See e.g., env.FixedTable for particular implementation of a fixed Table of patterns, for one example of a widely-used paradigm.

Typically each specific implementation of this Env interface will have multiple parameters etc that can be modified to control env behavior -- all of this is paradigm-specific and outside the scope of this basic interface.

Documentation

Overview

Package env defines an interface for environments, which determine the nature and sequence of States that can be used as inputs to a model and it can also accept Action responses from the model that affect how the enviroment evolves in the future.

By adhering to this interface, it is then easier to mix-and-match environments with models.

The overall division of labor is that the model keeps track of the outer-most Run time-scale depending on its own parameters and learning trajectory and the environment is responsible for generating patterns for each run.

Multiple different environments will typically be used in a model, e.g., one for training and other(s) for testing. Even if these envs all share a common database of patterns, a different Env should be used for each case where different counters and sequences of events etc are presented, which keeps them from interfering with each other. Also, the etable.IdxView can be used to allow multiple different Env's to all present different indexed views into a shared common etable.Table (e.g., train / test splits). The basic FixedTable env implementation uses this.

Thus, the Env encapsulates all of the counter management logic for each aspect of model training and testing, so that the model itself just needs to manange which Env to use, when, and manage the connection of the Env States as inputs to the model, and vice-versa for Actions on the Env coming from the model.

Each Element of the overall State allows annotation about the different elements of state that are available in general, and the `Step` should update all relevant state elements as appropriate, so these can be queried by the user. Particular paradigms of environments must establish naming conventions for these state elements which then allow the model to use the information appropriately -- the Env interface only provides the most basic framework for establishing these paradigms, and ultimately a given model will only work within a particular paradigm of environments following specific conventions.

See e.g., env.FixedTable for particular implementation of a fixed Table of patterns, for one example of a widely-used paradigm.

Typically each specific implementation of this Env interface will have multiple parameters etc that can be modified to control env behavior -- all of this is paradigm-specific and outside the scope of this basic interface.

See the emergent github wiki for more info: https://github.com/emer/emergent/wiki/Env

Index

Constants

View Source
const (
	// Event is the smallest unit of naturalistic experience that coheres unto itself
	// (e.g., something that could be described in a sentence).
	// Typically this is on the time scale of a few seconds: e.g., reaching for
	// something, catching a ball.  In an experiment it could just be the onset
	// of a stimulus, or the generation of a response.
	Event = TimeScales(etime.Event)

	// Trial is one unit of behavior in an experiment, and could potentially
	// encompass multiple Events (e.g., one event is fixation, next is stimulus,
	// last is response, all comprising one Trial).  It is also conventionally
	// used as a single Input / Output learning instance in a standard error-driven
	// learning paradigm.
	Trial = TimeScales(etime.Trial)

	// Tick is one step in a sequence -- often it is useful to have Trial count
	// up throughout the entire Epoch but also include a Tick to count trials
	// within a Sequence
	Tick = TimeScales(etime.Tick)

	// Sequence is a sequential group of Trials (not always needed).
	Sequence = TimeScales(etime.Sequence)

	// Block is a collection of Trials, Sequences or Events, often used in experiments
	// when conditions are varied across blocks.
	Block = TimeScales(etime.Block)

	// Condition is a collection of Blocks that share the same set of parameters.
	// This is intermediate between Block and Run levels.
	Condition = TimeScales(etime.Condition)

	// Epoch is used in two different contexts.  In machine learning, it represents a
	// collection of Trials, Sequences or Events that constitute a "representative sample"
	// of the environment.  In the simplest case, it is the entire collection of Trials
	// used for training.  In electrophysiology, it is a timing window used for organizing
	// the analysis of electrode data.
	Epoch = TimeScales(etime.Epoch)

	// Run is a complete run of a model / subject, from training to testing, etc.
	// Often multiple runs are done in an Expt to obtain statistics over initial
	// random weights etc.
	Run = TimeScales(etime.Run)

	// Expt is an entire experiment -- multiple Runs through a given protocol / set of
	// parameters.
	Expt = TimeScales(etime.Expt)

	// Scene is a sequence of events that constitutes the next larger-scale coherent unit
	// of naturalistic experience corresponding e.g., to a scene in a movie.
	// Typically consists of events that all take place in one location over
	// e.g., a minute or so. This could be a paragraph or a page or so in a book.
	Scene = TimeScales(etime.Scene)

	// Episode is a sequence of scenes that constitutes the next larger-scale unit
	// of naturalistic experience e.g., going to the grocery store or eating at a
	// restaurant, attending a wedding or other "event".
	// This could be a chapter in a book.
	Episode = TimeScales(etime.Episode)

	TimeScalesN = TimeScales(etime.TimesN)
)

The time scales

Variables

View Source
var KiT_TimeScales = kit.Enums.AddEnum(TimeScalesN, kit.NotBitFlag, nil)

Functions

func CounterChg

func CounterChg(en Env, scale TimeScales) bool

CounterChg returns whether counter changed during last Step() this Counter for Python because it cannot process multiple return values

func CounterCur

func CounterCur(en Env, scale TimeScales) int

CounterCur returns current counter state for given time scale this Counter for Python because it cannot process multiple return values

func CounterPrv

func CounterPrv(en Env, scale TimeScales) int

CounterPrv returns previous counter state for given time scale this Counter for Python because it cannot process multiple return values

func SchemaFromScales

func SchemaFromScales(ts []TimeScales) etable.Schema

SchemaFromScales returns an etable.Schema suitable for creating an etable.Table to record the given list of time scales. Can then add to this schema anything else that might be needed, before using it to create a Table.

Types

type Ctr

type Ctr struct {
	Cur   int        `desc:"current counter value"`
	Prv   int        `view:"-" desc:"previous counter value, prior to last Incr() call (init to -1)"`
	Chg   bool       `view:"-" desc:"did this change on the last Step() call or not?"`
	Max   int        `` /* 126-byte string literal not displayed */
	Scale TimeScales `view:"-" desc:"the unit of time scale represented by this counter (just FYI)"`
}

Ctr is a counter that counts increments at a given time scale. It keeps track of when it has been incremented or not, and retains the previous value.

func (*Ctr) Incr

func (ct *Ctr) Incr() bool

Incr increments the counter by 1. If Max > 0 then if Incr >= Max the counter is reset to 0 and true is returned. Otherwise false.

func (*Ctr) Init

func (ct *Ctr) Init()

Init initializes counter -- Cur = 0, Prv = -1

func (*Ctr) Query

func (ct *Ctr) Query() (cur, prv int, chg bool)

Query returns the current, previous and changed values for this counter

func (*Ctr) Same

func (ct *Ctr) Same()

Same resets Chg = false -- good idea to call this on all counters at start of Step or can put in an else statement, but that is more error-prone.

func (*Ctr) Set added in v1.1.4

func (ct *Ctr) Set(cur int) bool

Set sets the Cur value if different from Cur, while preserving previous value and setting Chg appropriately. Returns true if changed. does NOT check Cur vs. Max.

type Ctrs added in v1.3.2

type Ctrs struct {
	Order []TimeScales        `desc:"ordered list of the counter timescales, from outer-most (highest) to inner-most (lowest)"`
	Ctrs  map[TimeScales]*Ctr `desc:"map of the counters by timescale"`
}

Ctrs contains an ordered slice of timescales, and a lookup map of counters by timescale used to manage counters in the Env.

func (*Ctrs) ByScope added in v1.3.2

func (cs *Ctrs) ByScope(tm TimeScales) *Ctr

ByTime returns counter by timescale key -- nil if not found

func (*Ctrs) ByTimeTry added in v1.3.2

func (cs *Ctrs) ByTimeTry(tm TimeScales) (*Ctr, error)

ByTimeTry returns counter by timescale key -- returns nil, error if not found

func (*Ctrs) CtrsToStats added in v1.3.2

func (cs *Ctrs) CtrsToStats(mode string, stats *estats.Stats)

CtrsToStats sets the current counter values to estats Int values by their time names only (no eval Mode).

func (*Ctrs) Init added in v1.3.2

func (cs *Ctrs) Init()

Init does Init on all the counters

func (*Ctrs) SetTimes added in v1.3.2

func (cs *Ctrs) SetTimes(mode string, times ...TimeScales)

SetTimes initializes Ctrs for given mode and list of times ordered from highest to lowest

type CurPrvF32 added in v1.0.0

type CurPrvF32 struct {
	Cur float32 `desc:"current value"`
	Prv float32 `desc:"previous value"`
}

CurPrvF32 is basic state management for current and previous values, float32 values

func (*CurPrvF32) Diff added in v1.0.0

func (cv *CurPrvF32) Diff() float32

Diff returns the difference between current and previous values

func (*CurPrvF32) Incr added in v1.0.0

func (cv *CurPrvF32) Incr()

Incr increments Cur by 1

func (*CurPrvF32) Set added in v1.0.0

func (cv *CurPrvF32) Set(cur float32)

Set sets the new current value, copying Cur to Prv

type CurPrvInt added in v1.0.0

type CurPrvInt struct {
	Cur int `desc:"current value"`
	Prv int `desc:"previous value"`
}

CurPrvInt is basic state management for current and previous values, int values

func (*CurPrvInt) Diff added in v1.0.0

func (cv *CurPrvInt) Diff() int

Diff returns the difference between current and previous values

func (*CurPrvInt) Incr added in v1.0.0

func (cv *CurPrvInt) Incr()

Incr increments Cur by 1

func (*CurPrvInt) Set added in v1.0.0

func (cv *CurPrvInt) Set(cur int)

Set sets the new current value, copying Cur to Prv

type CurPrvString added in v1.0.0

type CurPrvString struct {
	Cur string `desc:"current value"`
	Prv string `desc:"previous value"`
}

CurPrvString is basic state management for current and previous values, string values

func (*CurPrvString) Set added in v1.0.0

func (cv *CurPrvString) Set(cur string)

Set sets the new current value, copying Cur to Prv

type Element

type Element struct {
	Name     string   `desc:"name of this element -- must be unique"`
	Shape    []int    `` /* 160-byte string literal not displayed */
	DimNames []string `desc:"names of the dimensions within the Shape -- optional but useful for ensuring correct usage"`
}

Element specifies one element of State or Action in an environment

func (*Element) FromColumn

func (ch *Element) FromColumn(sc *etable.Column)

FromColumn copies element data from etable Column that describes an etable.Table

type Elements

type Elements []Element

Elements is a list of Element info

func (*Elements) FromSchema

func (ch *Elements) FromSchema(sc etable.Schema)

FromSchema copies element data from a etable Schema that describes an etable.Table

type Env

type Env interface {
	// Name returns a name for this environment, which can be useful
	// for selecting from a list of options etc.
	Name() string

	// Desc returns an (optional) brief description of this particular
	// environment
	Desc() string

	// Validate checks if the various specific parameters for this
	// Env have been properly set -- if not, error message(s) will
	// be returned.  If everything is OK, nil is returned, in which
	// case calls to Counters(), States(), and Actions() should all
	// return valid data.  It is essential that a model *always* check
	// this as a first step, because the Env will not generally check
	// for errors on any subsequent calls (for greater efficiency
	// and simplicity) and this call can also establish certain general
	// initialization settings that are not run-specific and thus make
	// sense to do once at this point, not every time during Init().
	Validate() error

	// Init initializes the environment for a given run of the model.
	// The environment may not care about the run number, but may implement
	// different parameterizations for different runs (e.g., between-subject
	// manipulations).  In general the Env can expect that the model will likely
	// have established a different random seed per run, prior to calling this
	// method, and that may be sufficient to enable different run-level behavior.
	// All other initialization / updating beyond this outer-most Run level must
	// be managed internally by the Env itself, and the model can query the
	// Counter state information to determine when things have updated at different
	// time scales.  See Step() for important info about state of env after Init
	// but prior to first Step() call.
	Init(run int)

	// Step generates the next step of environment state.
	// This is the main API for how the model interacts with the environment --
	// the env should update all other levels of state internally over
	// repeated calls to the Step method.
	// If there are no further inputs available, it returns false (most envs
	// typically only return true and just continue running as long as needed).
	//
	// The Env thus always reflects the *current* state of things, and this
	// call increments that current state, such that subsequent calls to
	// State(), Counter() etc will return this current state.
	// This implies that the state just after Init and prior to first Step
	// call should be an *initialized* state that then allows the first Step
	// call to establish the proper *first* state.  Typically this means that
	// one or more counters will be set to -1 during Init and then get incremented
	// to 0 on the first Step call.
	Step() bool

	// Counter(scale TimeScales) returns current counter state for given time scale,
	// the immediate previous counter state, and whether that time scale changed
	// during the last Step() function call (this may be true even if cur == prv, if
	// the Max = 1).  Use the Ctr struct for each counter, which manages all of this.
	// See external Counter* methods for Python-safe single-return-value versions.
	Counter(scale TimeScales) (cur, prv int, changed bool)

	// State returns the given element's worth of tensor data from the environment
	// based on the current state of the env, as a function of having called Step().
	// If no output is available on that element, then nil is returned.
	// The returned tensor must be treated as read-only as it likely points to original
	// source data -- please make a copy before modifying (e.g., Clone() methdod)
	State(element string) etensor.Tensor

	// Action sends tensor data about e.g., responses from model back to act
	// on the environment and influence its subsequent evolution.
	// The nature and timing of this input is paradigm dependent.
	Action(element string, input etensor.Tensor)
}

Env defines an interface for environments, which determine the nature and sequence of States that can be used as inputs to a model, and the Env also can accept Action responses from the model that affect state evolution.

The Env encapsulates all of the counter management logic to advance the temporal state of the environment, using TimeScales standard intervals.

State is comprised of one or more Elements, each of which consists of an etensor.Tensor chunk of values that can be obtained by the model. Likewise, Actions can also have Elements. The Step method is the main interface for advancing the Env state. Counters should be queried after calling Step to see if any relevant values have changed, to trigger functions in the model (e.g., logging of prior statistics, etc).

Typically each specific implementation of this Env interface will have multiple parameters etc that can be modified to control env behavior -- all of this is paradigm-specific and outside the scope of this basic interface.

type EnvDesc added in v1.1.2

type EnvDesc interface {
	// Counters returns []TimeScales list of counters supported by this env.
	// These should be consistent within a paradigm and most models
	// will just expect particular sets of counters, but this can be
	// useful for sanity checking that a suitable env has been selected.
	// See SchemaFromScales function that takes this list of time
	// scales and returns an etable.Schema for Table columns to record
	// these counters in a log.
	Counters() []TimeScales

	// States returns a list of Elements of tensor outputs that this env
	// generates, specifying the unique Name and Shape of the data.
	// This information can be derived directly from an etable.Schema
	// and used for configuring model input / output pathways to fit
	// with those provided by the environment.  Depending on the
	// env paradigm, all elements may not be always available at every
	// point in time e.g., an env might alternate between Action and Reward
	// elements.  This may return nil if Env has not been properly
	// configured.
	States() Elements

	// Actions returns a list of elements of tensor inputs that this env
	// accepts, specifying the unique Name and Shape of the data.
	// Specific paradigms of envs can establish the timing and function
	// of these inputs, and how they then affect subsequent outputs
	// e.g., if the model is required to make a particular choice
	// response and then it can receive a reward or not contingent
	// on that choice.
	Actions() Elements
}

EnvDesc is an interface that defines methods that describe an Env. These are optional for basic Env, but in cases where an Env should be fully self-describing, these methods can be implemented.

type Envs added in v1.3.2

type Envs map[string]Env

Envs is a map of environments organized according to the evaluation mode string (recommended key value)

func (*Envs) Add added in v1.3.2

func (es *Envs) Add(evs ...Env)

Add adds Env(s), using its Name as the key

func (*Envs) ByMode added in v1.3.2

func (es *Envs) ByMode(mode etime.Modes) Env

ByMode returns env by etime.Modes evaluation mode as the map key. returns nil if not found

func (*Envs) Init added in v1.3.2

func (es *Envs) Init()

Init initializes the map if not yet

type FixedTable

type FixedTable struct {
	Nm         string          `desc:"name of this environment"`
	Dsc        string          `desc:"description of this environment"`
	Table      *etable.IdxView `` /* 285-byte string literal not displayed */
	Sequential bool            `` /* 140-byte string literal not displayed */
	Order      []int           `desc:"permuted order of items to present if not sequential -- updated every time through the list"`
	Run        Ctr             `view:"inline" desc:"current run of model as provided during Init"`
	Epoch      Ctr             `view:"inline" desc:"number of times through entire set of patterns"`
	Trial      Ctr             `` /* 164-byte string literal not displayed */
	TrialName  CurPrvString    `desc:"if Table has a Name column, this is the contents of that"`
	GroupName  CurPrvString    `desc:"if Table has a Group column, this is contents of that"`
	NameCol    string          `desc:"name of the Name column -- defaults to 'Name'"`
	GroupCol   string          `desc:"name of the Group column -- defaults to 'Group'"`
}

FixedTable is a basic Env that manages patterns from an etable.Table, with either sequential or permuted random ordering, and uses standard Trial / Epoch TimeScale counters to record progress and iterations through the table. It also records the outer loop of Run as provided by the model. It uses an IdxView indexed view of the Table, so a single shared table can be used across different environments, with each having its own unique view.

func (*FixedTable) Action

func (ft *FixedTable) Action(element string, input etensor.Tensor)

func (*FixedTable) Actions

func (ft *FixedTable) Actions() Elements

func (*FixedTable) Config added in v1.3.2

func (ft *FixedTable) Config(tbl *etable.IdxView)

Config configures the environment to use given table IndexView and evaluation mode (e.g., etime.Train.String()). If mode is Train then a Run counter is added, otherwise just Epoch and Trial. NameCol and GroupCol are initialized to "Name" and "Group" so set these to something else after this if needed.

func (*FixedTable) Counter

func (ft *FixedTable) Counter(scale TimeScales) (cur, prv int, chg bool)

func (*FixedTable) Counters

func (ft *FixedTable) Counters() []TimeScales

func (*FixedTable) Desc

func (ft *FixedTable) Desc() string

func (*FixedTable) Init

func (ft *FixedTable) Init(run int)

func (*FixedTable) Name

func (ft *FixedTable) Name() string

func (*FixedTable) NewOrder added in v1.0.0

func (ft *FixedTable) NewOrder()

NewOrder sets a new random Order based on number of rows in the table.

func (*FixedTable) PermuteOrder added in v1.0.0

func (ft *FixedTable) PermuteOrder()

PermuteOrder permutes the existing order table to get a new random sequence of inputs just calls: erand.PermuteInts(ft.Order)

func (*FixedTable) Row

func (ft *FixedTable) Row() int

Row returns the current row number in table, based on Sequential / perumuted Order and already de-referenced through the IdxView's indexes to get the actual row in the table.

func (*FixedTable) SetGroupName added in v1.0.0

func (ft *FixedTable) SetGroupName()

func (*FixedTable) SetTrialName

func (ft *FixedTable) SetTrialName()

func (*FixedTable) State

func (ft *FixedTable) State(element string) etensor.Tensor

func (*FixedTable) States

func (ft *FixedTable) States() Elements

func (*FixedTable) Step

func (ft *FixedTable) Step() bool

func (*FixedTable) Validate

func (ft *FixedTable) Validate() error

type FreqTable added in v1.0.0

type FreqTable struct {
	Nm         string          `desc:"name of this environment"`
	Dsc        string          `desc:"description of this environment"`
	Table      *etable.IdxView `` /* 285-byte string literal not displayed */
	NSamples   float64         `` /* 159-byte string literal not displayed */
	RndSamp    bool            `` /* 166-byte string literal not displayed */
	Sequential bool            `` /* 205-byte string literal not displayed */
	Order      []int           `desc:"list of items to present, with repetitions -- updated every time through the list"`
	Run        Ctr             `view:"inline" desc:"current run of model as provided during Init"`
	Epoch      Ctr             `view:"inline" desc:"number of times through entire set of patterns"`
	Trial      Ctr             `` /* 164-byte string literal not displayed */
	TrialName  CurPrvString    `desc:"if Table has a Name column, this is the contents of that"`
	GroupName  CurPrvString    `desc:"if Table has a Group column, this is contents of that"`
	NameCol    string          `desc:"name of the Name column -- defaults to 'Name'"`
	GroupCol   string          `desc:"name of the Group column -- defaults to 'Group'"`
	FreqCol    string          `desc:"name of the Freq column -- defaults to 'Freq'"`
}

FreqTable is an Env that manages patterns from an etable.Table with frequency information so that items are presented according to their associated frequencies which are effectively probabilities of presenting any given input -- must have a Freq column with these numbers in the table (actual col name in FreqCol). Either sequential or permuted random ordering is supported, with std Trial / Epoch TimeScale counters to record progress and iterations through the table. It also records the outer loop of Run as provided by the model. It uses an IdxView indexed view of the Table, so a single shared table can be used across different environments, with each having its own unique view.

func (*FreqTable) Action added in v1.0.0

func (ft *FreqTable) Action(element string, input etensor.Tensor)

func (*FreqTable) Actions added in v1.0.0

func (ft *FreqTable) Actions() Elements

func (*FreqTable) Counter added in v1.0.0

func (ft *FreqTable) Counter(scale TimeScales) (cur, prv int, chg bool)

func (*FreqTable) Counters added in v1.0.0

func (ft *FreqTable) Counters() []TimeScales

func (*FreqTable) Desc added in v1.0.0

func (ft *FreqTable) Desc() string

func (*FreqTable) Init added in v1.0.0

func (ft *FreqTable) Init(run int)

func (*FreqTable) Name added in v1.0.0

func (ft *FreqTable) Name() string

func (*FreqTable) Row added in v1.0.0

func (ft *FreqTable) Row() int

Row returns the current row number in table, based on Sequential / perumuted Order and already de-referenced through the IdxView's indexes to get the actual row in the table.

func (*FreqTable) Sample added in v1.0.0

func (ft *FreqTable) Sample()

Sample generates a new sample of items

func (*FreqTable) SetGroupName added in v1.0.0

func (ft *FreqTable) SetGroupName()

func (*FreqTable) SetTrialName added in v1.0.0

func (ft *FreqTable) SetTrialName()

func (*FreqTable) State added in v1.0.0

func (ft *FreqTable) State(element string) etensor.Tensor

func (*FreqTable) States added in v1.0.0

func (ft *FreqTable) States() Elements

func (*FreqTable) Step added in v1.0.0

func (ft *FreqTable) Step() bool

func (*FreqTable) Validate added in v1.0.0

func (ft *FreqTable) Validate() error

type MPIFixedTable added in v1.3.29

type MPIFixedTable struct {
	Nm         string          `desc:"name of this environment"`
	Dsc        string          `desc:"description of this environment"`
	Table      *etable.IdxView `` /* 285-byte string literal not displayed */
	Sequential bool            `` /* 140-byte string literal not displayed */
	Order      []int           `desc:"permuted order of items to present if not sequential -- updated every time through the list"`
	Run        Ctr             `view:"inline" desc:"current run of model as provided during Init"`
	Epoch      Ctr             `view:"inline" desc:"number of times through entire set of patterns"`
	Trial      Ctr             `` /* 164-byte string literal not displayed */
	TrialName  CurPrvString    `desc:"if Table has a Name column, this is the contents of that"`
	GroupName  CurPrvString    `desc:"if Table has a Group column, this is contents of that"`
	NameCol    string          `desc:"name of the Name column -- defaults to 'Name'"`
	GroupCol   string          `desc:"name of the Group column -- defaults to 'Group'"`
	TrialSt    int             `desc:"for MPI, trial we start each epoch on, as index into Order"`
	TrialEd    int             `desc:"for MPI, trial number we end each epoch before (i.e., when ctr gets to Ed, restarts)"`
}

MPIFixedTable is an MPI-enabled version of the FixedTable, which is a basic Env that manages patterns from an etable.Table, with either sequential or permuted random ordering, and uses standard Trial / Epoch TimeScale counters to record progress and iterations through the table. It also records the outer loop of Run as provided by the model. It uses an IdxView indexed view of the Table, so a single shared table can be used across different environments, with each having its own unique view. The MPI version distributes trials across MPI procs, in the Order list. It is ESSENTIAL that the number of trials (rows) in Table is evenly divisible by number of MPI procs! If all nodes start with the same seed, it should remain synchronized.

func (*MPIFixedTable) Action added in v1.3.29

func (ft *MPIFixedTable) Action(element string, input etensor.Tensor)

func (*MPIFixedTable) Actions added in v1.3.29

func (ft *MPIFixedTable) Actions() Elements

func (*MPIFixedTable) Counter added in v1.3.29

func (ft *MPIFixedTable) Counter(scale TimeScales) (cur, prv int, chg bool)

func (*MPIFixedTable) Counters added in v1.3.29

func (ft *MPIFixedTable) Counters() []TimeScales

func (*MPIFixedTable) Desc added in v1.3.29

func (ft *MPIFixedTable) Desc() string

func (*MPIFixedTable) Init added in v1.3.29

func (ft *MPIFixedTable) Init(run int)

func (*MPIFixedTable) Name added in v1.3.29

func (ft *MPIFixedTable) Name() string

func (*MPIFixedTable) NewOrder added in v1.3.29

func (ft *MPIFixedTable) NewOrder()

NewOrder sets a new random Order based on number of rows in the table.

func (*MPIFixedTable) PermuteOrder added in v1.3.29

func (ft *MPIFixedTable) PermuteOrder()

PermuteOrder permutes the existing order table to get a new random sequence of inputs just calls: erand.PermuteInts(ft.Order)

func (*MPIFixedTable) Row added in v1.3.29

func (ft *MPIFixedTable) Row() int

Row returns the current row number in table, based on Sequential / perumuted Order and already de-referenced through the IdxView's indexes to get the actual row in the table.

func (*MPIFixedTable) SetGroupName added in v1.3.29

func (ft *MPIFixedTable) SetGroupName()

func (*MPIFixedTable) SetTrialName added in v1.3.29

func (ft *MPIFixedTable) SetTrialName()

func (*MPIFixedTable) State added in v1.3.29

func (ft *MPIFixedTable) State(element string) etensor.Tensor

func (*MPIFixedTable) States added in v1.3.29

func (ft *MPIFixedTable) States() Elements

func (*MPIFixedTable) Step added in v1.3.29

func (ft *MPIFixedTable) Step() bool

func (*MPIFixedTable) Validate added in v1.3.29

func (ft *MPIFixedTable) Validate() error

type TimeScales

type TimeScales etime.Times

TimeScales are the different time scales associated with overall simulation running, and can be used to parameterize the updating and control flow of simulations at different scales. The definitions become increasingly subjective imprecise as the time scales increase. Environments can implement updating along different such time scales as appropriate. This list is designed to standardize terminology across simulations and establish a common conceptual framework for time -- it can easily be extended in specific simulations to add needed additional levels, although using one of the existing standard values is recommended wherever possible.

func StringToTimeScales added in v1.3.2

func StringToTimeScales(s string) (TimeScales, error)

func (TimeScales) MarshalJSON

func (ev TimeScales) MarshalJSON() ([]byte, error)

func (TimeScales) String

func (i TimeScales) String() string

func (*TimeScales) UnmarshalJSON

func (ev *TimeScales) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL