Documentation ¶
Index ¶
- Constants
- Variables
- type Context
- func (ctx *Context) ClosestPat(layNm, unitVar string, pats *etable.Table, colnm, namecol string) (int, float32, string)
- func (ctx *Context) ItemFloat(mode etime.Modes, time etime.Times, itemNm string) float64
- func (ctx *Context) ItemFloatScope(scope etime.ScopeKey, itemNm string) float64
- func (ctx *Context) ItemString(mode etime.Modes, time etime.Times, itemNm string) string
- func (ctx *Context) ItemStringScope(scope etime.ScopeKey, itemNm string) string
- func (ctx *Context) LastNRows(mode etime.Modes, time etime.Times, n int) *etable.IdxView
- func (ctx *Context) LastNRowsScope(sk etime.ScopeKey, n int) *etable.IdxView
- func (ctx *Context) Layer(layNm string) emer.Layer
- func (ctx *Context) SetAgg(mode etime.Modes, time etime.Times, ag agg.Aggs) float64
- func (ctx *Context) SetAggItem(mode etime.Modes, time etime.Times, itemNm string, ag agg.Aggs) float64
- func (ctx *Context) SetAggItemScope(scope etime.ScopeKey, itemNm string, ag agg.Aggs) float64
- func (ctx *Context) SetAggScope(scope etime.ScopeKey, ag agg.Aggs) float64
- func (ctx *Context) SetFloat32(val float32)
- func (ctx *Context) SetFloat64(val float64)
- func (ctx *Context) SetInt(val int)
- func (ctx *Context) SetLayerRepTensor(layNm, unitVar string) *etensor.Float32
- func (ctx *Context) SetLayerTensor(layNm, unitVar string) *etensor.Float32
- func (ctx *Context) SetStatFloat(name string)
- func (ctx *Context) SetStatInt(name string)
- func (ctx *Context) SetStatString(name string)
- func (ctx *Context) SetString(val string)
- func (ctx *Context) SetTable(sk etime.ScopeKey, lt *LogTable, row int)
- func (ctx *Context) SetTensor(val etensor.Tensor)
- type Item
- func (item *Item) CompileScopes()
- func (item *Item) HasMode(mode etime.Modes) bool
- func (item *Item) HasTime(time etime.Times) bool
- func (item *Item) SetEachScopeKey()
- func (item *Item) SetWriteFunc(mode etime.Modes, time etime.Times, theFunc WriteFunc)
- func (item *Item) SetWriteFuncAll(theFunc WriteFunc)
- func (item *Item) SetWriteFuncOver(modes []etime.Modes, times []etime.Times, theFunc WriteFunc)
- func (item *Item) WriteFunc(mode, time string) (WriteFunc, bool)
- type LogTable
- type Logs
- func (lg *Logs) AddCounterItems(ctrs ...etime.Times)
- func (lg *Logs) AddErrStatAggItems(statName string, times ...etime.Times)
- func (lg *Logs) AddItem(item *Item)
- func (lg *Logs) AddLayerTensorItems(net emer.Network, varNm string, mode etime.Modes, etm etime.Times, ...)
- func (lg *Logs) AddPerTrlMSec(itemName string, times ...etime.Times)
- func (lg *Logs) AddStatAggItem(itemName, statName string, plot bool, times ...etime.Times)
- func (lg *Logs) AddStatFloatNoAggItem(mode etime.Modes, etm etime.Times, stats ...string)
- func (lg *Logs) AddStatIntNoAggItem(mode etime.Modes, etm etime.Times, stats ...string)
- func (lg *Logs) AddStatStringItem(mode etime.Modes, etm etime.Times, stats ...string)
- func (lg *Logs) CloseLogFiles()
- func (lg *Logs) CompileAllScopes()
- func (lg *Logs) CreateTables() error
- func (lg *Logs) IdxView(mode etime.Modes, time etime.Times) *etable.IdxView
- func (lg *Logs) IdxViewScope(sk etime.ScopeKey) *etable.IdxView
- func (lg *Logs) InitErrStats()
- func (lg *Logs) ItemBindAllScopes(item *Item)
- func (lg *Logs) ItemByName(name string) (*Item, bool)
- func (lg *Logs) Log(mode etime.Modes, time etime.Times) *etable.Table
- func (lg *Logs) LogRow(mode etime.Modes, time etime.Times, row int) *etable.Table
- func (lg *Logs) LogRowScope(sk etime.ScopeKey, row int) *etable.Table
- func (lg *Logs) LogScope(sk etime.ScopeKey) *etable.Table
- func (lg *Logs) MPIGatherTableRows(mode etime.Modes, time etime.Times, comm *mpi.Comm)
- func (lg *Logs) MiscTable(name string) *etable.Table
- func (lg *Logs) NamedIdxView(mode etime.Modes, time etime.Times, name string) (*etable.IdxView, bool)
- func (lg *Logs) NamedIdxViewScope(sk etime.ScopeKey, name string) (*etable.IdxView, bool)
- func (lg *Logs) NewTable(mode, time string) *etable.Table
- func (lg *Logs) NoPlot(mode etime.Modes, time etime.Times)
- func (lg *Logs) NoPlotScope(sk etime.ScopeKey)
- func (lg *Logs) ProcessItems()
- func (lg *Logs) ResetLog(mode etime.Modes, time etime.Times)
- func (lg *Logs) RunStats(stats ...string)
- func (lg *Logs) SetContext(stats *estats.Stats, net emer.Network)
- func (lg *Logs) SetLogFile(mode etime.Modes, time etime.Times, fnm string)
- func (lg *Logs) SetMeta(mode etime.Modes, time etime.Times, key, val string)
- func (lg *Logs) SetMetaScope(sk etime.ScopeKey, key, val string)
- func (lg *Logs) Table(mode etime.Modes, time etime.Times) *etable.Table
- func (lg *Logs) TableDetails(mode etime.Modes, time etime.Times) *LogTable
- func (lg *Logs) TableDetailsScope(sk etime.ScopeKey) *LogTable
- func (lg *Logs) TableScope(sk etime.ScopeKey) *etable.Table
- func (lg *Logs) WriteItems(sk etime.ScopeKey, row int)
- func (lg *Logs) WriteLastRowToFile(lt *LogTable)
- type WriteFunc
- type WriteMap
Constants ¶
const ( // DTrue is deprecated -- just use true DTrue = true // DFalse is deprecated -- just use false DFalse = false )
const LogPrec = 4
LogPrec is precision for saving float values in logs
Variables ¶
var LogDir = ""
LogDir is a directory that is prefixed for saving log files
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct { Logs *Logs `desc:"pointer to the Logs object with all log data"` Stats *estats.Stats `desc:"pointer to stats"` Net emer.Network `desc:"network"` Item *Item `desc:"current log Item"` Scope etime.ScopeKey `desc:"current scope key"` Mode etime.Modes `desc:"current scope eval mode (if standard)"` Time etime.Times `desc:"current scope timescale (if standard)"` LogTable *LogTable `desc:"LogTable with extra data for the table"` Table *etable.Table `desc:"current table to record value to"` Row int `desc:"current row in table to write to"` }
Context provides the context for logging Write functions. SetContext must be called on Logs to set the Stats and Net values Provides various convenience functions for setting log values and other commonly-used operations.
func (*Context) ClosestPat ¶
func (ctx *Context) ClosestPat(layNm, unitVar string, pats *etable.Table, colnm, namecol string) (int, float32, string)
ClosestPat finds the closest pattern in given column of given pats table to given layer activation pattern using given variable. Returns the row number, correlation value, and value of a column named namecol for that row if non-empty. Column must be etensor.Float32
func (*Context) ItemFloat ¶
ItemFloat returns a float64 value of the last row of given item name in log for given mode, time
func (*Context) ItemFloatScope ¶
ItemFloatScope returns a float64 value of the last row of given item name in log for given scope.
func (*Context) ItemString ¶
ItemString returns a string value of the last row of given item name in log for given mode, time
func (*Context) ItemStringScope ¶
ItemStringScope returns a string value of the last row of given item name in log for given scope.
func (*Context) LastNRows ¶
LastNRows returns an IdxView onto table for given scope with the last n rows of the table (only valid rows, if less than n). This index view is available later with the "LastNRows" name via NamedIdxView functions.
func (*Context) LastNRowsScope ¶
LastNRowsScope returns an IdxView onto table for given scope with the last n rows of the table (only valid rows, if less than n). This index view is available later with the "LastNRows" name via NamedIdxView functions.
func (*Context) Layer ¶
Layer returns layer by name as the emer.Layer interface -- you may then need to convert to a concrete type depending.
func (*Context) SetAgg ¶
SetAgg sets an aggregated scalar value computed from given eval mode and time scale with same Item name, to current item, row. returns aggregated value
func (*Context) SetAggItem ¶
func (ctx *Context) SetAggItem(mode etime.Modes, time etime.Times, itemNm string, ag agg.Aggs) float64
SetAggItem sets an aggregated scalar value computed from given eval mode and time scale with given Item name, to current item, row. returns aggregated value
func (*Context) SetAggItemScope ¶
SetAggItemScope sets an aggregated scalar value computed from another scope (ScopeKey) with given Item name, to current item, row. returns aggregated value
func (*Context) SetAggScope ¶
SetAggScope sets an aggregated scalar value computed from another scope (ScopeKey) with same Item name, to current item, row returns aggregated value
func (*Context) SetFloat32 ¶
SetFloat32 sets a float32 to current table, item, row
func (*Context) SetFloat64 ¶
SetFloat64 sets a float64 to current table, item, row
func (*Context) SetLayerRepTensor ¶ added in v1.1.55
SetLayerRepTensor sets tensor of representative Unit values on a layer for given variable
func (*Context) SetLayerTensor ¶
SetLayerTensor sets tensor of Unit values on a layer for given variable
func (*Context) SetStatFloat ¶
SetStatFloat sets a Stats Float of given name to current table, item, row
func (*Context) SetStatInt ¶
SetStatInt sets a Stats int of given name to current table, item, row
func (*Context) SetStatString ¶
SetStatString sets a Stats string of given name to current table, item, row
type Item ¶
type Item struct { Name string `desc:"name of column -- must be unique for a table"` Type etensor.Type `desc:"data type, using etensor types which are isomorphic with arrow.Type"` CellShape []int `` /* 168-byte string literal not displayed */ DimNames []string `desc:"names of the dimensions within the CellShape -- 'Row' will be added to outer dimension"` Write WriteMap `` /* 263-byte string literal not displayed */ Plot bool `desc:"Whether or not to plot it"` Range minmax.F64 `desc:"The minimum and maximum values, for plotting"` FixMin bool `desc:"Whether to fix the minimum in the display"` FixMax bool `desc:"Whether to fix the maximum in the display"` ErrCol string `desc:"Name of other item that has the error bar values for this item -- for plotting"` TensorIdx int `desc:"index of tensor to plot -- defaults to 0 -- use -1 to plot all"` Color string `desc:"specific color for plot -- uses default ordering of colors if empty"` // following are updated in final Process step Modes map[string]bool `desc:"map of eval modes that this item has a Write function for"` Times map[string]bool `desc:"map of times that this item has a Write function for"` }
Item describes one item to be logged -- has all the info for this item, across all scopes where it is relevant.
func (*Item) CompileScopes ¶
func (item *Item) CompileScopes()
CompileScopes compiles maps of modes and times where this item appears. Based on the final updated Write map
func (*Item) SetEachScopeKey ¶
func (item *Item) SetEachScopeKey()
SetEachScopeKey updates the Write map so that it only contains entries for a unique Mode,Time pair, where multiple modes and times may have originally been specified.
func (*Item) SetWriteFunc ¶
SetWriteFunc sets Write function for one mode, time
func (*Item) SetWriteFuncAll ¶
SetWriteFuncAll sets the Write function for all existing Modes and Times Can be used to replace a Write func after the fact.
func (*Item) SetWriteFuncOver ¶
SetWriteFuncOver sets the Write function over range of modes and times
type LogTable ¶
type LogTable struct { Table *etable.Table `desc:"Actual data stored."` Meta map[string]string `desc:"arbitrary meta-data for each table, e.g., hints for plotting: Plot = false to not plot, XAxisCol, LegendCol"` IdxView *etable.IdxView `view:"-" desc:"Index View of the table -- automatically updated when a new row of data is logged to the table."` NamedViews map[string]*etable.IdxView `` /* 196-byte string literal not displayed */ File *os.File `view:"-" desc:"File to store the log into."` WroteHeaders bool `view:"-" desc:"true if headers for File have already been written"` }
LogTable contains all the data for one log table
func NewLogTable ¶
NewLogTable returns a new LogTable entry for given table, initializing values
func (*LogTable) GetIdxView ¶
GetIdxView returns the index view for the whole table. It is reset to nil after log row is written, and if nil then it is initialized to reflect current rows.
func (*LogTable) NamedIdxView ¶
NamedIdxView returns a named Index View of the table, and true if this index view was newly created to show entire table (else false). This is used for additional data aggregation, filtering etc. It is reset to nil after log row is written, and if nil then it is initialized to reflect current rows as a starting point (returning true). Thus, the bool return value can be used for re-using cached indexes.
func (*LogTable) ResetIdxViews ¶
func (lt *LogTable) ResetIdxViews()
ResetIdxViews resets all IdxViews -- after log row is written
type Logs ¶
type Logs struct { Tables map[etime.ScopeKey]*LogTable `desc:"Tables storing log data, auto-generated from Items."` MiscTables map[string]*etable.Table `desc:"holds additional tables not computed from items -- e.g., aggregation results, intermediate computations, etc"` Items []*Item `` /* 167-byte string literal not displayed */ Context Context `` /* 171-byte string literal not displayed */ Modes map[string]bool `view:"-" desc:"All the eval modes that appear in any of the items of this log."` Times map[string]bool `view:"-" desc:"All the timescales that appear in any of the items of this log."` ItemIdxMap map[string]int `view:"-" desc:"map of item indexes by name, for rapid access to items if they need to be modified after adding."` TableOrder []etime.ScopeKey `view:"-" desc:"sorted order of table scopes"` }
Logs contains all logging state and API for doing logging. do AddItem to add any number of items, at different eval mode, time scopes. Each Item has its own Write functions, at each scope as neeeded. Then call CreateTables to generate log Tables from those items. Call Log with a scope to add a new row of data to the log and ResetLog to reset the log to empty.
func (*Logs) AddCounterItems ¶ added in v1.3.3
AddCounterItems adds given Int counters from Stats, typically by recording looper counter values to Stats.
func (*Logs) AddErrStatAggItems ¶ added in v1.3.3
AddErrStatAggItems adds Err, PctErr, PctCor items recording overall performance from the given statName statistic (e.g., "TrlErr") across the 3 time scales, ordered from higher to lower, e.g., Run, Epoch, Trial.
func (*Logs) AddItem ¶
AddItem adds an item to the list. The items are stored in the order they are added, and this order is used for calling the item Write functions, so you can rely on that ordering for any sequential dependencies across items (e.g., in using intermediate computed values). Note: item names must be unique -- use different scopes for Write functions where needed.
func (*Logs) AddLayerTensorItems ¶ added in v1.3.9
func (lg *Logs) AddLayerTensorItems(net emer.Network, varNm string, mode etime.Modes, etm etime.Times, layClasses ...string)
AddLayerTensorItems adds tensor recording items for given variable, classes of layers, mode and time (e.g., Test, Trial). If another item already exists for a different mode / time, this is added to it so there aren't any duplicate items.
func (*Logs) AddPerTrlMSec ¶ added in v1.3.3
AddPerTrlMSec adds a log item that records PerTrlMSec log item that records the time taken to process one trial. itemName is PerTrlMSec by default. and times are relevant 3 times to record, ordered higher to lower, e.g., Run, Epoch, Trial
func (*Logs) AddStatAggItem ¶ added in v1.3.3
AddStatAggItem adds a Float64 stat that is aggregated across the 3 time scales, ordered from higher to lower, e.g., Run, Epoch, Trial. The itemName is what is saved in the table, and statName is the source statistic in stats at the lowest level.
func (*Logs) AddStatFloatNoAggItem ¶ added in v1.3.3
AddStatFloatNoAggItem adds float statistic(s) of given names for just one mode, time, with no aggregation. If another item already exists for a different mode / time, this is added to it so there aren't any duplicate items.
func (*Logs) AddStatIntNoAggItem ¶ added in v1.3.3
AddStatIntNoAggItem adds int statistic(s) of given names for just one mode, time, with no aggregation. If another item already exists for a different mode / time, this is added to it so there aren't any duplicate items.
func (*Logs) AddStatStringItem ¶ added in v1.3.13
AddStatStringItem adds string stat item(s) to given mode and time (e.g., Allmodes, Trial). If another item already exists for a different mode / time, this is added to it so there aren't any duplicate items.
func (*Logs) CloseLogFiles ¶
func (lg *Logs) CloseLogFiles()
CloseLogFiles closes all open log files
func (*Logs) CompileAllScopes ¶
func (lg *Logs) CompileAllScopes()
CompileAllScopes gathers all the modes and times used across all items
func (*Logs) CreateTables ¶
CreateTables creates the log tables based on all the specified log items It first calls ProcessItems to instantiate specific scopes.
func (*Logs) IdxView ¶
IdxView returns the Index View of a log table for a given mode, time This is used for data aggregation functions over the entire table. It should not be altered (don't Filter!) and always shows the whole table. See NamedIdxView for custom index views.
func (*Logs) IdxViewScope ¶
IdxViewScope returns the Index View of a log table for given etime.ScopeKey This is used for data aggregation functions over the entire table. This view should not be altered and always shows the whole table. See NamedIdxView for custom index views.
func (*Logs) InitErrStats ¶ added in v1.3.4
func (lg *Logs) InitErrStats()
InitErrStats initializes the base stats variables used for AddErrStatAggItems: TrlErr, FirstZero, LastZero, NZero
func (*Logs) ItemBindAllScopes ¶
ItemBindAllScopes translates the AllModes or AllTimes scopes into a concrete list of actual Modes and Times used across all items
func (*Logs) ItemByName ¶ added in v1.3.9
ItemByName returns item by given name, false if not found
func (*Logs) Log ¶
Log performs logging for given mode, time. Adds a new row and Writes all the items. and saves data to file if open.
func (*Logs) LogRow ¶
LogRow performs logging for given mode, time, at given row. Saves data to file if open.
func (*Logs) LogRowScope ¶
LogRowScope performs logging for given etime.ScopeKey, at given row. Saves data to file if open.
func (*Logs) LogScope ¶
LogScope performs logging for given etime.ScopeKey Adds a new row and Writes all the items. and saves data to file if open.
func (*Logs) MPIGatherTableRows ¶ added in v1.1.57
MPIGatherTableRows calls empi.GatherTableRows on the given log table using an "MPI" suffixed MiscTable that is then switched out with the main table, so that any subsequent aggregation etc operates as usual on the full set of data. IMPORTANT: this switch means that the number of rows in the table MUST be reset back to either 0 (e.g., ResetLog) or the target number of rows, after the table is used, otherwise it will grow exponentially!
func (*Logs) MiscTable ¶
MiscTable gets a miscellaneous table that is not specified or typically expected
func (*Logs) NamedIdxView ¶
func (lg *Logs) NamedIdxView(mode etime.Modes, time etime.Times, name string) (*etable.IdxView, bool)
NamedIdxView returns a named Index View of a log table for a given mode, time. This is used for additional data aggregation, filtering etc. When accessing the first time during writing a new row of the log, it automatically shows a view of the entire table and returns true for 2nd arg. You can then filter, sort, etc as needed. Subsequent calls within same row Write will return the last filtered view, and false for 2nd arg -- can then just reuse view.
func (*Logs) NamedIdxViewScope ¶
NamedIdxView returns a named Index View of a log table for a given mode, time. This is used for additional data aggregation, filtering etc. When accessing the first time during writing a new row of the log, it automatically shows a view of the entire table and returns true for 2nd arg. You can then filter, sort, etc as needed. Subsequent calls within same row Write will return the last filtered view, and false for 2nd arg -- can then just reuse view.
func (*Logs) NoPlot ¶
NoPlot sets meta data to not plot for given scope mode, time. Typically all combinations of mode and time end up being generated, so you have to turn off plotting of cases not used.
func (*Logs) NoPlotScope ¶
NoPlotScope sets meta data to not plot for given scope mode, time. Typically all combinations of mode and time end up being generated, so you have to turn off plotting of cases not used.
func (*Logs) ProcessItems ¶
func (lg *Logs) ProcessItems()
ProcessItems is called in CreateTables, after all items have been added. It instantiates All scopes, and compiles multi-list scopes into single mode, item pairs
func (*Logs) ResetLog ¶
ResetLog resets the log for given mode, time, at given row. by setting number of rows = 0 The IdxViews are reset too.
func (*Logs) RunStats ¶ added in v1.3.3
RunStats records descriptive values for given stats across all runs, at Train Run scope, saving to RunStats misc table
func (*Logs) SetContext ¶
SetContext sets the Context for logging Write functions to give general access to the stats and network
func (*Logs) SetLogFile ¶
SetLogFile sets the log filename for given scope
func (*Logs) SetMetaScope ¶
SetMetaScope sets table meta data for given scope
func (*Logs) TableDetails ¶
TableDetails returns the LogTable record of associated info for given table
func (*Logs) TableDetailsScope ¶
TableDetailsScope returns the LogTable record of associated info for given table
func (*Logs) TableScope ¶
TableScope returns the table for given etime.ScopeKey
func (*Logs) WriteItems ¶
WriteItems calls all item Write functions within given scope providing the relevant Context for the function. Items are processed in the order added, to enable sequential dependencies to be used.
func (*Logs) WriteLastRowToFile ¶
WriteLastRowToFile writes the last row of table to file, if File != nil