Documentation ¶
Overview ¶
Package params provides general-purpose parameter management functionality for organizing multiple sets of parameters efficiently, and basic IO for saving / loading from JSON files and generating Go code to embed into applications, and a basic GUI for viewing and editing.
The main overall unit that is generally operated upon at run-time is the params.Set, which is a collection of params.Sheet's (akin to CSS style sheets) that constitute a coherent set of parameters.
A good strategy is to have a "Base" Set that has all the best parameters so far, and then other sets can modify specific params relative to that one. Order of application is critical, as subsequent params applications overwrite earlier ones, and the typical order is:
- Defaults() method called that establishes the hard-coded default parameters.
- Then apply "Base" params.Set for any changes relative to those.
- Then optionally apply one or more additional params.Set's with current experimental parameters.
Critically, all of this is entirely up to the particular model program(s) to determine and control -- this package just provides the basic data structures for holding all of the parameters, and the IO / and Apply infrastructure.
Within a params.Set, multiple different params.Sheet's can be organized, with each CSS-style sheet achieving a relatively complete parameter styling of a given element of the overal model, e.g., "Network", "Sim", "Env". Or Network could be further broken down into "Learn" vs. "Act" etc, or according to different brain areas ("Hippo", "PFC", "BG", etc). Again, this is entirely at the discretion of the modeler and must be performed under explict program control, especially because order is so critical.
Each params.Sheet consists of a collection of params.Sel elements which actually finally contain the parameters. The Sel field specifies a CSS-style selector determining over what scope the parameters should be applied:
* Type = name of a type -- anything having this type name will get these params.
* .Class = anything with a given class label (each object can have multiple Class labels and thus receive multiple parameter settings, but again, order matters!)
* #Name = a specific named object.
The order of application within a given Sheet is also critical -- typically put the most general Type params first, then .Class, then the most specific #Name cases, to achieve within a given Sheet the same logic of establishing Base params for all types and then more specific overrides for special cases (e.g., an overall learning rate that appplies across all projections, but maybe a faster or slower one for a .Class or specific #Name'd projection).
There is a params.Styler interface with methods that any Go type can implement to provide these different labels. The emer.Network, .Layer, and .Prjn interfaces each implement this interface.
Otherwise, the Apply method will just directly apply params to a given struct type if it does not implement the Styler interface.
Parameter values are limited to float64 values *only*. These can be specified using "enum" style const integer values, and can be applied to any numeric type (they will be automatically converted), but internally this is the only parameter value type, which greatly simplifies the overall interface, and handles the vast majority of use-cases (especially because named options are just integers and can be set as such).
Finally, there are methods to show where params.Set's set the same parameter differently, and to compare with the default settings on a given object type using go struct field tags of the form def:"val1[,val2...]".
Index ¶
- Variables
- func ClassMatch(sel, cls string) bool
- func FindParam(val reflect.Value, path string) (reflect.Value, error)
- func GetParam(obj interface{}, path string) (float64, error)
- func SelMatch(sel string, name, cls, styp, gotyp string) bool
- func SetParam(obj interface{}, path string, val string) error
- func WriteGoPrelude(w io.Writer, varNm string)
- type Flex
- func (fl *Flex) ApplySheet(sheet *Sheet, setMsg bool)
- func (fl *Flex) Class() string
- func (fl *Flex) CopyFrom(cp Flex)
- func (fl *Flex) Init(vals []FlexVal)
- func (fl *Flex) JSONString() string
- func (fl *Flex) Make()
- func (fl *Flex) Name() string
- func (fl *Flex) SaveJSON(filename gi.FileName) error
- func (fl *Flex) TypeName() string
- func (fl *Flex) WriteJSON(w io.Writer) error
- type FlexVal
- type HyperVals
- type Hypers
- func (pr *Hypers) Apply(obj interface{}, setMsg bool) error
- func (pr *Hypers) CopyFrom(cp Hypers)
- func (pr *Hypers) DeleteValOnly()
- func (pr *Hypers) OpenJSON(filename gi.FileName) error
- func (pr *Hypers) ParamByName(name string) map[string]string
- func (pr *Hypers) ParamByNameTry(name string) (map[string]string, error)
- func (pr *Hypers) Path(path string) string
- func (pr *Hypers) SaveGoCode(filename gi.FileName) error
- func (pr *Hypers) SaveJSON(filename gi.FileName) error
- func (pr *Hypers) SetByName(name string, value map[string]string)
- func (pr *Hypers) StringGoCode() []byte
- func (pr *Hypers) TargetType() string
- func (pr *Hypers) WriteGoCode(w io.Writer, depth int)
- type Params
- func (pr *Params) Apply(obj interface{}, setMsg bool) error
- func (pr *Params) Diffs(op *Params, nm1, nm2 string) string
- func (pr *Params) OpenJSON(filename gi.FileName) error
- func (pr *Params) ParamByName(name string) string
- func (pr *Params) ParamByNameTry(name string) (string, error)
- func (pr *Params) Path(path string) string
- func (pr *Params) SaveGoCode(filename gi.FileName) error
- func (pr *Params) SaveJSON(filename gi.FileName) error
- func (pr *Params) SetByName(name, value string)
- func (pr *Params) StringGoCode() []byte
- func (pr *Params) TargetType() string
- func (pr *Params) WriteGoCode(w io.Writer, depth int)
- type Sel
- func (ps *Sel) Apply(obj interface{}, setMsg bool) (bool, error)
- func (pr *Sel) OpenJSON(filename gi.FileName) error
- func (sl *Sel) ParamVal(param string) (string, error)
- func (pr *Sel) SaveGoCode(filename gi.FileName) error
- func (pr *Sel) SaveJSON(filename gi.FileName) error
- func (ps *Sel) SelMatch(obj interface{}) bool
- func (sl *Sel) SetFloat(param string, val float64)
- func (sl *Sel) SetString(param string, val string)
- func (pr *Sel) StringGoCode() []byte
- func (ps *Sel) TargetTypeMatch(obj interface{}) bool
- func (pr *Sel) WriteGoCode(w io.Writer, depth int)
- type Set
- func (ps *Set) Diffs(ops *Set) string
- func (ps *Set) DiffsWithin() string
- func (pr *Set) OpenJSON(filename gi.FileName) error
- func (ps *Set) ParamVal(sheet, sel, param string) (string, error)
- func (pr *Set) SaveGoCode(filename gi.FileName) error
- func (pr *Set) SaveJSON(filename gi.FileName) error
- func (ps *Set) SetFloat(sheet, sel, param string, val float64) error
- func (ps *Set) SetString(sheet, sel, param string, val string) error
- func (ps *Set) SheetByName(name string) *Sheet
- func (ps *Set) SheetByNameTry(name string) (*Sheet, error)
- func (pr *Set) StringGoCode() []byte
- func (ps *Set) ValidateSheets(valids []string) error
- func (pr *Set) WriteGoCode(w io.Writer, depth int)
- type Sets
- func (ps *Sets) DiffsAll() string
- func (ps *Sets) DiffsFirst() string
- func (ps *Sets) DiffsWithin(setName string) string
- func (ps *Sets) ElemLabel(idx int) string
- func (pr *Sets) OpenJSON(filename gi.FileName) error
- func (ps *Sets) ParamVal(set, sheet, sel, param string) (string, error)
- func (pr *Sets) SaveGoCode(filename gi.FileName) error
- func (pr *Sets) SaveJSON(filename gi.FileName) error
- func (ps *Sets) SetByName(name string) *Set
- func (ps *Sets) SetByNameTry(name string) (*Set, error)
- func (ps *Sets) SetFloat(set, sheet, sel, param string, val float64) error
- func (ps *Sets) SetString(set, sheet, sel, param string, val string) error
- func (pr *Sets) StringGoCode() []byte
- func (ps *Sets) ValidateSheets(valids []string) error
- func (pr *Sets) WriteGoCode(w io.Writer, depth int)
- type Sheet
- func (ps *Sheet) Apply(obj interface{}, setMsg bool) (bool, error)
- func (ps *Sheet) Diffs(ops *Sheet, setNm1, setNm2 string) string
- func (ps *Sheet) DiffsWithin(shtNm string) string
- func (sh *Sheet) ElemLabel(idx int) string
- func (pr *Sheet) OpenJSON(filename gi.FileName) error
- func (sh *Sheet) ParamVal(sel, param string) (string, error)
- func (pr *Sheet) SaveGoCode(filename gi.FileName) error
- func (pr *Sheet) SaveJSON(filename gi.FileName) error
- func (sh *Sheet) SelByName(sel string) *Sel
- func (sh *Sheet) SelByNameTry(sel string) (*Sel, error)
- func (sh *Sheet) SetFloat(sel, param string, val float64) error
- func (sh *Sheet) SetString(sel, param string, val string) error
- func (pr *Sheet) StringGoCode() []byte
- func (pr *Sheet) WriteGoCode(w io.Writer, depth int)
- type Sheets
- type Styler
- type StylerObj
Constants ¶
This section is empty.
Variables ¶
var HypersProps = ki.Props{ "ToolBar": ki.PropSlice{ {"SaveJSON", ki.Props{ "label": "Save As...", "desc": "save to JSON formatted file", "icon": "file-save", "Args": ki.PropSlice{ {"File Name", ki.Props{ "ext": ".params", }}, }, }}, {"OpenJSON", ki.Props{ "label": "Open...", "desc": "open from JSON formatted file", "icon": "file-open", "Args": ki.PropSlice{ {"File Name", ki.Props{ "ext": ".params", }}, }, }}, {"sep-gocode", ki.BlankProp{}}, {"SaveGoCode", ki.Props{ "label": "Save Code As...", "desc": "save to Go-formatted initializer code in file", "icon": "go", "Args": ki.PropSlice{ {"File Name", ki.Props{ "ext": ".go", }}, }, }}, {"StringGoCode", ki.Props{ "label": "Show Code", "desc": "shows the Go-formatted initializer code, can be copy / pasted into program", "icon": "go", "show-return": true, }}, }, }
var KiT_Hypers = kit.Types.AddType(&Hypers{}, HypersProps)
var KiT_Params = kit.Types.AddType(&Params{}, ParamsProps)
var KiT_Sel = kit.Types.AddType(&Sel{}, SelProps)
var KiT_Set = kit.Types.AddType(&Set{}, SetProps)
var KiT_Sets = kit.Types.AddType(&Sets{}, SetsProps)
var KiT_Sheet = kit.Types.AddType(&Sheet{}, SheetProps)
var KiT_Sheets = kit.Types.AddType(&Sheets{}, SheetsProps)
var ParamsProps = ki.Props{ "ToolBar": ki.PropSlice{ {"SaveJSON", ki.Props{ "label": "Save As...", "desc": "save to JSON formatted file", "icon": "file-save", "Args": ki.PropSlice{ {"File Name", ki.Props{ "ext": ".params", }}, }, }}, {"OpenJSON", ki.Props{ "label": "Open...", "desc": "open from JSON formatted file", "icon": "file-open", "Args": ki.PropSlice{ {"File Name", ki.Props{ "ext": ".params", }}, }, }}, {"sep-gocode", ki.BlankProp{}}, {"SaveGoCode", ki.Props{ "label": "Save Code As...", "desc": "save to Go-formatted initializer code in file", "icon": "go", "Args": ki.PropSlice{ {"File Name", ki.Props{ "ext": ".go", }}, }, }}, {"StringGoCode", ki.Props{ "label": "Show Code", "desc": "shows the Go-formatted initializer code, can be copy / pasted into program", "icon": "go", "show-return": true, }}, }, }
var SelProps = ki.Props{ "ToolBar": ki.PropSlice{ {"SaveJSON", ki.Props{ "label": "Save As...", "desc": "save to JSON formatted file", "icon": "file-save", "Args": ki.PropSlice{ {"File Name", ki.Props{ "ext": ".params", }}, }, }}, {"OpenJSON", ki.Props{ "label": "Open...", "desc": "open from JSON formatted file", "icon": "file-open", "Args": ki.PropSlice{ {"File Name", ki.Props{ "ext": ".params", }}, }, }}, {"sep-gocode", ki.BlankProp{}}, {"SaveGoCode", ki.Props{ "label": "Save Code As...", "desc": "save to Go-formatted initializer code in file", "icon": "go", "Args": ki.PropSlice{ {"File Name", ki.Props{ "ext": ".go", }}, }, }}, {"StringGoCode", ki.Props{ "label": "Show Code", "desc": "shows the Go-formatted initializer code, can be copy / pasted into program", "icon": "go", "show-return": true, }}, }, }
var SetProps = ki.Props{ "ToolBar": ki.PropSlice{ {"SaveJSON", ki.Props{ "label": "Save As...", "desc": "save to JSON formatted file", "icon": "file-save", "Args": ki.PropSlice{ {"File Name", ki.Props{ "ext": ".params", }}, }, }}, {"OpenJSON", ki.Props{ "label": "Open...", "desc": "open from JSON formatted file", "icon": "file-open", "Args": ki.PropSlice{ {"File Name", ki.Props{ "ext": ".params", }}, }, }}, {"sep-gocode", ki.BlankProp{}}, {"SaveGoCode", ki.Props{ "label": "Save Code As...", "desc": "save to Go-formatted initializer code in file", "icon": "go", "Args": ki.PropSlice{ {"File Name", ki.Props{ "ext": ".go", }}, }, }}, {"StringGoCode", ki.Props{ "label": "Show Code", "desc": "shows the Go-formatted initializer code, can be copy / pasted into program", "icon": "go", "show-return": true, }}, {"sep-diffs", ki.BlankProp{}}, {"DiffsWithin", ki.Props{ "desc": "reports where the same param path is being set to different values within this set (both within the same Sheet and betwen sheets)", "icon": "search", "show-return": true, }}, }, }
var SetsProps = ki.Props{ "ToolBar": ki.PropSlice{ {"SaveJSON", ki.Props{ "label": "Save As...", "desc": "save to JSON formatted file", "icon": "file-save", "Args": ki.PropSlice{ {"File Name", ki.Props{ "ext": ".params", }}, }, }}, {"OpenJSON", ki.Props{ "label": "Open...", "desc": "open from JSON formatted file", "icon": "file-open", "Args": ki.PropSlice{ {"File Name", ki.Props{ "ext": ".params", }}, }, }}, {"sep-gocode", ki.BlankProp{}}, {"SaveGoCode", ki.Props{ "label": "Save Code As...", "desc": "save to Go-formatted initializer code in file", "icon": "go", "Args": ki.PropSlice{ {"File Name", ki.Props{ "ext": ".go", }}, }, }}, {"StringGoCode", ki.Props{ "label": "Show Code", "desc": "shows the Go-formatted initializer code, can be copy / pasted into program", "icon": "go", "show-return": true, }}, {"sep-diffs", ki.BlankProp{}}, {"DiffsAll", ki.Props{ "desc": "between all sets, reports where the same param path is being set to different values", "icon": "search", "show-return": true, }}, {"DiffsFirst", ki.Props{ "desc": "between first set (e.g., the Base set) and rest of sets, reports where the same param path is being set to different values", "icon": "search", "show-return": true, }}, {"DiffsWithin", ki.Props{ "desc": "reports all the cases where the same param path is being set to different values within different sheets in given set", "icon": "search", "show-return": true, "Args": ki.PropSlice{ {"Set Name", ki.Props{}}, }, }}, }, }
var SheetProps = ki.Props{ "ToolBar": ki.PropSlice{ {"SaveJSON", ki.Props{ "label": "Save As...", "desc": "save to JSON formatted file", "icon": "file-save", "Args": ki.PropSlice{ {"File Name", ki.Props{ "ext": ".params", }}, }, }}, {"OpenJSON", ki.Props{ "label": "Open...", "desc": "open from JSON formatted file", "icon": "file-open", "Args": ki.PropSlice{ {"File Name", ki.Props{ "ext": ".params", }}, }, }}, {"sep-gocode", ki.BlankProp{}}, {"SaveGoCode", ki.Props{ "label": "Save Code As...", "desc": "save to Go-formatted initializer code in file", "icon": "go", "Args": ki.PropSlice{ {"File Name", ki.Props{ "ext": ".go", }}, }, }}, {"StringGoCode", ki.Props{ "label": "Show Code", "desc": "shows the Go-formatted initializer code, can be copy / pasted into program", "icon": "go", "show-return": true, }}, }, }
var SheetsProps = ki.Props{ "ToolBar": ki.PropSlice{ {"SaveJSON", ki.Props{ "label": "Save As...", "desc": "save to JSON formatted file", "icon": "file-save", "Args": ki.PropSlice{ {"File Name", ki.Props{ "ext": ".params", }}, }, }}, {"OpenJSON", ki.Props{ "label": "Open...", "desc": "open from JSON formatted file", "icon": "file-open", "Args": ki.PropSlice{ {"File Name", ki.Props{ "ext": ".params", }}, }, }}, {"sep-gocode", ki.BlankProp{}}, {"SaveGoCode", ki.Props{ "label": "Save Code As...", "desc": "save to Go-formatted initializer code in file", "icon": "go", "Args": ki.PropSlice{ {"File Name", ki.Props{ "ext": ".go", }}, }, }}, {"StringGoCode", ki.Props{ "label": "Show Code", "desc": "shows the Go-formatted initializer code, can be copy / pasted into program", "icon": "go", "show-return": true, }}, {"sep-diffs", ki.BlankProp{}}, {"DiffsWithin", ki.Props{ "desc": "reports where the same param path is being set to different values within this set (both within the same Sheet and betwen sheets)", "icon": "search", "show-return": true, }}, }, }
Functions ¶
func ClassMatch ¶
ClassMatch returns true if given class names -- handles space-separated multiple class names
func FindParam ¶
FindParam parses the path and recursively tries to find the parameter pointed to by the path (dot-delimited field names). Returns error if not found, and always also emits error messages -- the target type should already have been identified and this should only be called when there is an expectation of the path working.
func GetParam ¶
GetParam gets parameter value at given path on given object. converts target type to float64. returns error if path not found or target is not a numeric type (always logged).
func SetParam ¶
SetParam sets parameter at given path on given object to given value converts the string param val as appropriate for target type. returns error if path not found or cannot set (always logged).
func WriteGoPrelude ¶
WriteGoPrelude writes the start of a go file in package main that starts a variable assignment to given variable -- for start of SaveGoCode methods.
Types ¶
type Flex ¶ added in v1.1.51
Flex supports arbitrary named parameter values that can be set by a Set of parameters, as a map of interface{} objects. First initialize the map with set of names and a type to create blank values, then apply the Set to it.
func (*Flex) ApplySheet ¶ added in v1.1.51
ApplySheet applies given sheet of parameters to each element in Flex
func (*Flex) JSONString ¶ added in v1.1.51
JSONString returns a string representation of Flex params
func (*Flex) Make ¶ added in v1.1.51
func (fl *Flex) Make()
Make makes the map if it is nil (otherwise does nothing)
type FlexVal ¶ added in v1.1.51
type FlexVal struct { Nm string `desc:"name of this specific object -- matches #Name selections"` Type string `desc:"type name of this object -- matches plain TypeName selections"` Cls string `desc:"space-separated list of class name(s) -- match the .Class selections"` Obj interface{} `desc:"actual object with data that is set by the parameters"` }
FlexVal is a specific flexible value for the Flex parameter map that implements the StylerObj interface for CSS-style selection logic
type HyperVals ¶ added in v1.1.51
HyperVals is a string-value map for storing hyperparameter values
func (*HyperVals) JSONString ¶ added in v1.1.51
JSONString returns hyper values as a JSON formatted string
func (*HyperVals) SetJSONString ¶ added in v1.1.51
SetJSONString sets from a JSON_formatted string
type Hypers ¶ added in v1.1.50
Hypers is a parallel structure to Params which stores information relevant to hyperparameter search as well as the values. Use the key "Val" for the default value. This is equivalant to the value in Params. "Min" and "Max" guid the range, and "Sigma" describes a Gaussian.
func (*Hypers) Apply ¶ added in v1.1.50
Apply applies all parameter values to given object. Object must already be the appropriate target type based on the first element of the path (see TargetType method). If setMsg is true, then it will log a confirmation that the parameter was set (it always prints an error message if it fails to set the parameter at given path, and returns error if so).
func (*Hypers) DeleteValOnly ¶ added in v1.1.51
func (pr *Hypers) DeleteValOnly()
DeleteValOnly deletes entries that only have a "Val" entry. This happens when applying a param Sheet using Flex params to compile values using styling logic
func (*Hypers) ParamByName ¶ added in v1.1.50
ParamByName returns given parameter by name (just does the map access) Returns "" if not found -- use Try version for error
func (*Hypers) ParamByNameTry ¶ added in v1.1.50
ParamByNameTry returns given parameter, by name. Returns error if not found.
func (*Hypers) Path ¶ added in v1.1.50
Path returns the second part of the path after the target type, indicating the path to the specific parameter being set.
func (*Hypers) SaveGoCode ¶ added in v1.1.50
SaveGoCode saves hypers to corresponding Go initializer code.
func (*Hypers) SetByName ¶ added in v1.1.58
SetByName sets given parameter by name to given value. (just a wrapper around map set function)
func (*Hypers) StringGoCode ¶ added in v1.1.50
StringGoCode returns Go initializer code as a byte string.
func (*Hypers) TargetType ¶ added in v1.1.50
TargetType returns the first part of the path, indicating what type of object the params apply to. Uses the first item in the map (which is random) everything in the map must have the same target.
type Params ¶
Params is a name-value map for parameter values that can be applied to any numeric type in any object. The name must be a dot-separated path to a specific parameter, e.g., Prjn.Learn.Lrate The first part of the path is the overall target object type, e.g., "Prjn" or "Layer", which is used for determining if the parameter applies to a given object type.
All of the params in one map must apply to the same target type because only the first item in the map (which could be any due to order randomization) is used for checking the type of the target. Also, they all fall within the same Sel selector scope which is used to determine what specific objects to apply the parameters to.
func (*Params) Apply ¶
Apply applies all parameter values to given object. Object must already be the appropriate target type based on the first element of the path (see TargetType method). If setMsg is true, then it will log a confirmation that the parameter was set (it always prints an error message if it fails to set the parameter at given path, and returns error if so).
func (*Params) Diffs ¶
Diffs returns comparison between all params in this params versus the other params, where the path is the same but the parameter value is different. Nm1 is the name / id of the 'this' Params, and nm2 is for the other params.
func (*Params) ParamByName ¶ added in v1.0.0
ParamByName returns given parameter by name (just does the map access) Returns "" if not found -- use Try version for error
func (*Params) ParamByNameTry ¶ added in v1.0.0
ParamByNameTry returns given parameter, by name. Returns error if not found.
func (*Params) Path ¶
Path returns the second part of the path after the target type, indicating the path to the specific parameter being set.
func (*Params) SaveGoCode ¶
SaveGoCode saves params to corresponding Go initializer code.
func (*Params) SetByName ¶ added in v1.1.58
SetByName sets given parameter by name to given value. (just a wrapper around map set function)
func (*Params) StringGoCode ¶
StringGoCode returns Go initializer code as a byte string.
func (*Params) TargetType ¶
TargetType returns the first part of the path, indicating what type of object the params apply to. Uses the first item in the map (which is random) everything in the map must have the same target.
type Sel ¶
type Sel struct { Sel string `` /* 279-byte string literal not displayed */ Desc string `` /* 180-byte string literal not displayed */ Params Params `view:"no-inline" desc:"parameter values to apply to whatever matches the selector"` Hypers Hypers `desc:"Put your hyperparams here"` }
params.Sel specifies a selector for the scope of application of a set of parameters, using standard css selector syntax (. prefix = class, # prefix = name, and no prefix = type)
func (*Sel) Apply ¶
Apply checks if Sel selector applies to this object according to (.Class, #Name, Type) using the params.Styler interface, and returns false if it does not. The TargetType of the Params is always tested against the obj's type name first. If it does apply, or is not a Styler, then the Params values are set. If setMsg is true, then a message is printed to confirm each parameter that is set. It always prints a message if a parameter fails to be set, and returns an error.
func (*Sel) SaveGoCode ¶
SaveGoCode saves params to corresponding Go initializer code.
func (*Sel) StringGoCode ¶
StringGoCode returns Go initializer code as a byte string.
func (*Sel) TargetTypeMatch ¶
TargetTypeMatch return true if target type applies to object
type Set ¶
type Set struct { Name string `desc:"unique name of this set of parameters"` Desc string `width:"60" desc:"description of this param set -- when should it be used? how is it different from the other sets?"` Sheets Sheets `` /* 337-byte string literal not displayed */ }
Set is a collection of Sheet's that constitute a coherent set of parameters -- a particular specific configuration of parameters, which the user selects to use. A good strategy is to have a "Base" set that has all the best parameters so far, and then other sets can modify relative to that one. It is up to the Sim code to apply parameter sets in whatever order is desired.
Within a params.Set, multiple different params.Sheet's can be organized, with each CSS-style sheet achieving a relatively complete parameter styling of a given element of the overal model, e.g., "Network", "Sim", "Env". Or Network could be further broken down into "Learn" vs. "Act" etc, or according to different brain areas ("Hippo", "PFC", "BG", etc). Again, this is entirely at the discretion of the modeler and must be performed under explict program control, especially because order is so critical.
Note that there is NO deterministic ordering of the Sheets due to the use of a Go map structure, which specifically randomizes order, so simply iterating over them and applying may produce unexpected results -- it is better to lookup by name.
func (*Set) Diffs ¶
Diffs reports all the cases where the same param path is being set to different values between this set and the other set.
func (*Set) DiffsWithin ¶
DiffsWithin reports all the cases where the same param path is being set to different values within different sheets
func (*Set) ParamVal ¶ added in v1.1.57
ParamVal returns the value of given parameter, in selection sel, in sheet
func (*Set) SaveGoCode ¶
SaveGoCode saves params to corresponding Go initializer code.
func (*Set) SetFloat ¶ added in v1.1.58
SetFloat sets the value of given parameter, in selection sel, in sheet
func (*Set) SetString ¶ added in v1.1.58
SetString sets the value of given parameter, in selection sel, in sheet
func (*Set) SheetByName ¶ added in v1.0.0
SheetByName finds given sheet by name -- returns nil if not found. Use this when sure the sheet exists -- otherwise use Try version.
func (*Set) SheetByNameTry ¶
SheetByNameTry tries to find given sheet by name, and returns error if not found (also logs the error)
func (*Set) StringGoCode ¶
StringGoCode returns Go initializer code as a byte string.
func (*Set) ValidateSheets ¶
ValidateSheets ensures that the sheet names are among those listed -- returns error message for any that are not. Helps catch typos and makes sure params are applied properly. Automatically logs errors.
type Sets ¶
type Sets []*Set
Sets is a collection of Set's that can be chosen among depending on different desired configurations etc. Thus, each Set represents a collection of different possible specific configurations, and different such configurations can be chosen by name to apply as desired.
func (*Sets) DiffsAll ¶
DiffsAll reports all the cases where the same param path is being set to different values across different sets
func (*Sets) DiffsFirst ¶
DiffsFirst reports all the cases where the same param path is being set to different values between the first set (e.g., the "Base" set) and all other sets
func (*Sets) DiffsWithin ¶
DiffsWithin reports all the cases where the same param path is being set to different values within different sheets in given set
func (*Sets) ElemLabel ¶
ElemLabel satisfies the gi.SliceLabeler interface to provide labels for slice elements
func (*Sets) ParamVal ¶ added in v1.1.57
ParamVal returns the value of given parameter, in selection sel, in sheet and set. Returns error if anything is not found.
func (*Sets) SaveGoCode ¶
SaveGoCode saves params to corresponding Go initializer code.
func (*Sets) SetByName ¶
SetByName returns given set by name -- for use when confident that it exists, as a nil will return if not found with no error
func (*Sets) SetByNameTry ¶
SetByNameTry tries to find given set by name, and returns error if not found (also logs the error)
func (*Sets) SetFloat ¶ added in v1.1.58
SetFloat sets the value of given parameter, in selection sel, in sheet and set.
func (*Sets) SetString ¶ added in v1.1.58
SetString sets the value of given parameter, in selection sel, in sheet and set. Returns error if anything is not found.
func (*Sets) StringGoCode ¶
StringGoCode returns Go initializer code as a byte string.
func (*Sets) ValidateSheets ¶
ValidateSheets ensures that the sheet names are among those listed -- returns error message for any that are not. Helps catch typos and makes sure params are applied properly. Automatically logs errors.
type Sheet ¶
type Sheet []*Sel
Sheet is a CSS-like style-sheet of params.Sel values, each of which represents a different set of specific parameter values applied according to the Sel selector: .Class #Name or Type.
The order of elements in the Sheet list is critical, as they are applied in the order given by the list (slice), and thus later Sel's can override those applied earlier. Thus, you generally want to have more general Type-level parameters listed first, and then subsequently more specific ones (.Class and #Name)
This is the highest level of params that has an Apply method -- above this level application must be done under explicit program control.
func (*Sheet) Apply ¶
Apply applies entire sheet to given object, using param.Sel's in order see param.Sel.Apply() for details. returns true if any Sel's applied, and error if any errors. If setMsg is true, then a message is printed to confirm each parameter that is set. It always prints a message if a parameter fails to be set, and returns an error.
func (*Sheet) Diffs ¶
Diffs reports all the cases where the same param path is being set to different values between this sheeet and the other sheeet.
func (*Sheet) DiffsWithin ¶
DiffsWithin reports all the cases where the same param path is being set to different values within different Sel's in this Sheet.
func (*Sheet) ElemLabel ¶
ElemLabel satisfies the gi.SliceLabeler interface to provide labels for slice elements
func (*Sheet) ParamVal ¶ added in v1.1.57
ParamVal returns the value of given parameter, in selection sel
func (*Sheet) SaveGoCode ¶
SaveGoCode saves params to corresponding Go initializer code.
func (*Sheet) SelByName ¶ added in v1.0.0
SelByName returns given selector within the Sheet, by Name. Returns nil if not found -- use Try version for error
func (*Sheet) SelByNameTry ¶ added in v1.0.0
SelByNameTry returns given selector within the Sheet, by Name. Returns nil and error if not found.
func (*Sheet) SetFloat ¶ added in v1.1.58
SetFloat sets the value of given parameter, in selection sel
func (*Sheet) SetString ¶ added in v1.1.58
SetString sets the value of given parameter, in selection sel
func (*Sheet) StringGoCode ¶
StringGoCode returns Go initializer code as a byte string.
type Sheets ¶
Sheets is a map of named sheets -- used in the Set
func (*Sheets) DiffsWithin ¶
DiffsWithin reports all the cases where the same param path is being set to different values within different sheets
func (*Sheets) SaveGoCode ¶
SaveGoCode saves params to corresponding Go initializer code.
func (*Sheets) StringGoCode ¶
StringGoCode returns Go initializer code as a byte string.
type Styler ¶
type Styler interface { // TypeName returns the name of this type. CSS Sel selector with no prefix // operates on type name. This type is used *in addition* to the actual // Go type name of the object, and is a kind of type-category (e.g., Layer // or Prjn in emergent network objects) TypeName() string // Class returns the space-separated list of class selectors (tags). // Parameters with a . prefix target class tags. // Do NOT include the. in the Class tags on Styler objects however // -- those are only in the Sel selector on the params.Sel. Class() string // Name returns the name of this object. // Parameters with a # prefix target object names, which are typically // unique. Note, do not include the # prefix in the Styler name. Name() string }
The params.Styler interface exposes TypeName, Class, and Name methods that allow the params.Sel CSS-style selection specifier to determine whether a given parameter applies. Adding Set versions of Name and Class methods is a good idea but not needed for this interface, so they are not included here.
type StylerObj ¶ added in v1.1.51
type StylerObj interface { Styler // Object recturns the object that will have its field values set by // the params specifications. Object() interface{} }
The params.StylerObj interface extends Styler to include an arbitary function to access the underlying object type.