netview

package
v2.0.0-dev0.1.8 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2026 License: BSD-3-Clause Imports: 48 Imported by: 9

README

Docs: GoDoc

Package netview provides the NetView type that displays a neural network using the emer.Layer etc interfaces defined in the emer package.

Documentation

Overview

Package netview provides the NetView interactive 3D network viewer, implemented in the Cogent Core 3D framework.

Index

Constants

View Source
const NaNSub = -1.11e-37

NaNSub is used to replace NaN values for saving -- JSON doesn't handle nan's

Variables

View Source
var MinUnitHeight = float32(1.0e-6)

MinUnitHeight ensures that there is always at least some dimensionality to the unit cubes -- affects transparency rendering etc

View Source
var NVarCols = 2

NVarCols is the default number of variable columns in the NetView

View Source
var NilColor = color.RGBA{0x20, 0x20, 0x20, 0x40}

Functions

func FormDialog

func FormDialog(ctx core.Widget, v any, title string)

FormDialog opens a dialog in a new, separate window for viewing / editing the given struct object, in the context of the given ctx widget.

Types

type LayData

type LayData struct {

	// the layer name
	LayName string

	// cached number of units
	NUnits int

	// the full data, in that order
	Data []float32

	// receiving pathway data -- shared with SendPaths
	RecvPaths []*PathData

	// sending pathway data -- shared with RecvPaths
	SendPaths []*PathData
}

LayData maintains a record of all the data for a given layer

func (*LayData) AllocSendPaths

func (ld *LayData) AllocSendPaths(ly emer.Layer)

AllocSendPaths allocates Sending pathways for given layer. does nothing if already allocated.

func (*LayData) FreePaths

func (ld *LayData) FreePaths()

FreePaths nils path data -- for NoSynDat

type LayMesh

type LayMesh struct {
	xyz.MeshBase

	// layer that we render
	Lay emer.Layer

	// current shape that has been constructed -- if same, just update
	Shape tensor.Shape

	// netview that we're in
	View *NetView
}

LayMesh is a xyz.Mesh that represents a layer -- it is dynamically updated using the Update method which only resets the essential Vertex elements. The geometry is literal in the layer size: 0,0,0 lower-left corner and increasing X,Z for the width and height of the layer, in unit (1) increments per unit.. NetView applies an overall scaling to make it fit within the larger view.

func NewLayMesh

func NewLayMesh(sc *xyz.Scene, nv *NetView, lay emer.Layer) *LayMesh

NewLayMesh adds LayMesh mesh to given scene for given layer

func (*LayMesh) MeshSize

func (lm *LayMesh) MeshSize() (nVtx, nIndex int, hasColor bool)

func (*LayMesh) RasterSet2DX

func (lm *LayMesh) RasterSet2DX(vtxAry, normAry, texAry, clrAry math32.ArrayF32, idxAry math32.ArrayU32)

func (*LayMesh) RasterSet2DZ

func (lm *LayMesh) RasterSet2DZ(vtxAry, normAry, texAry, clrAry math32.ArrayF32, idxAry math32.ArrayU32)

func (*LayMesh) RasterSet4DX

func (lm *LayMesh) RasterSet4DX(vtxAry, normAry, texAry, clrAry math32.ArrayF32, idxAry math32.ArrayU32)

func (*LayMesh) RasterSet4DZ

func (lm *LayMesh) RasterSet4DZ(vtxAry, normAry, texAry, clrAry math32.ArrayF32, idxAry math32.ArrayU32)

func (*LayMesh) RasterSize2D

func (lm *LayMesh) RasterSize2D() (nVtx, nIndex int)

func (*LayMesh) RasterSize4D

func (lm *LayMesh) RasterSize4D() (nVtx, nIndex int)

func (*LayMesh) Set

func (lm *LayMesh) Set(vtxAry, normAry, texAry, clrAry math32.ArrayF32, idxAry math32.ArrayU32)

func (*LayMesh) Set2D

func (lm *LayMesh) Set2D(vtxAry, normAry, texAry, clrAry math32.ArrayF32, idxAry math32.ArrayU32)

func (*LayMesh) Set4D

func (lm *LayMesh) Set4D(vtxAry, normAry, texAry, clrAry math32.ArrayF32, idxAry math32.ArrayU32)

func (*LayMesh) Size2D

func (lm *LayMesh) Size2D() (nVtx, nIndex int)

func (*LayMesh) Size4D

func (lm *LayMesh) Size4D() (nVtx, nIndex int)

type LayName

type LayName struct {
	xyz.Text2D

	// our netview
	NetView *NetView `copier:"-" json:"-" xml:"-" display:"-"`
}

LayName is the Layer name as a Text2D within the NetView

func NewLayName

func NewLayName(parent ...tree.Node) *LayName

NewLayName returns a new LayName with the given optional parent: LayName is the Layer name as a Text2D within the NetView

func (*LayName) SetNetView

func (t *LayName) SetNetView(v *NetView) *LayName

SetNetView sets the [LayName.NetView]: our netview

type LayObj

type LayObj struct {
	xyz.Solid

	// name of the layer we represent
	LayName string

	// our netview
	NetView *NetView `copier:"-" json:"-" xml:"-" display:"-"`
}

LayObj is the Layer 3D object within the NetView

func NewLayObj

func NewLayObj(parent ...tree.Node) *LayObj

NewLayObj returns a new LayObj with the given optional parent: LayObj is the Layer 3D object within the NetView

func (*LayObj) SetLayName

func (t *LayObj) SetLayName(v string) *LayObj

SetLayName sets the [LayObj.LayName]: name of the layer we represent

func (*LayObj) SetNetView

func (t *LayObj) SetNetView(v *NetView) *LayObj

SetNetView sets the [LayObj.NetView]: our netview

type NetData

type NetData struct {

	// the network that we're viewing
	Net emer.Network `json:"-"`

	// copied from Params -- do not record synapse level data -- turn this on for very large networks where recording the entire synaptic state would be prohibitive
	NoSynData bool

	// name of the layer with unit for viewing pathways (connection / synapse-level values)
	PathLay string

	// 1D index of unit within PathLay for for viewing pathways
	PathUnIndex int

	// copied from NetView Params: if non-empty, this is the type pathway to show when there are multiple pathways from the same layer -- e.g., Inhib, Lateral, Forward, etc
	PathType string `edit:"-"`

	// the list of unit variables saved
	UnVars []string

	// index of each variable in the Vars slice
	UnVarIndexes map[string]int

	// the list of synaptic variables saved
	SynVars []string

	// index of synaptic variable in the SynVars slice
	SynVarIndexes map[string]int

	// the circular ring index -- Max here is max number of values to store, Len is number stored, and Index(Len-1) is the most recent one, etc
	Ring ringidx.Index

	// max data parallel data per unit
	MaxData int

	// the layer data -- map keyed by layer name
	LayData map[string]*LayData

	// unit var min values for each Ring.Max * variable
	UnMinPer []float32

	// unit var max values for each Ring.Max * variable
	UnMaxPer []float32

	// min values for unit variables
	UnMinVar []float32

	// max values for unit variables
	UnMaxVar []float32

	// min values for syn variables
	SynMinVar []float32

	// max values for syn variables
	SynMaxVar []float32

	// counter strings
	Counters []string

	// raster counter values
	RasterCtrs []int

	// map of raster counter values to record numbers
	RasterMap map[int]int

	// dummy raster counter when passed a -1 -- increments and wraps around
	RastCtr int
}

NetData maintains a record of all the network data that has been displayed up to a given maximum number of records (updates), using efficient ring index logic with no copying to store in fixed-sized buffers.

func (*NetData) Config

func (nd *NetData) Config()

Config configures the data storage for given network only re-allocates if needed.

func (*NetData) CounterRec

func (nd *NetData) CounterRec(recno int) string

CounterRec returns counter string for given record, which is -1 for current (last) record, or in [0..Len-1] for prior records.

func (*NetData) Init

func (nd *NetData) Init(net emer.Network, max int, noSynData bool, maxData int)

Init initializes the main params and configures the data

func (*NetData) OpenJSON

func (nd *NetData) OpenJSON(filename core.Filename) error

OpenJSON opens colors from a JSON-formatted file.

func (*NetData) RasterCtr

func (nd *NetData) RasterCtr(recno int) (int, bool)

RasterCtr returns the raster counter value at given record number (-1 = current)

func (*NetData) ReadJSON

func (nd *NetData) ReadJSON(r io.Reader) error

ReadJSON reads netdata from JSON format

func (*NetData) RecIndex

func (nd *NetData) RecIndex(recno int) int

RecIndex returns record index for given record number, which is -1 for current (last) record, or in [0..Len-1] for prior records.

func (*NetData) Record

func (nd *NetData) Record(ctrs string, rastCtr, rastMax int)

Record records the current full set of data from the network, and the given counters string (displayed at bottom of window) and raster counter value -- if negative, then an internal wraping-around counter is used.

func (*NetData) RecordLastCtrs

func (nd *NetData) RecordLastCtrs(ctrs string)

RecordLastCtrs records just the last counter string to be the given string overwriting what was there before.

func (*NetData) RecordSyns

func (nd *NetData) RecordSyns()

RecordSyns records synaptic data -- stored separate from unit data and only needs to be called when synaptic values are updated. Should be done when the DWt values have been computed, before updating Wts and zeroing. NetView displays this recorded data when Update is next called.

func (*NetData) RecvUnitValue

func (nd *NetData) RecvUnitValue(laynm string, vnm string, uidx1d int) (float32, bool)

RecvUnitVal returns the value for given layer, variable name, unit index, for receiving pathway variable, based on recorded synaptic pathway data. Returns false if value unavailable for any reason (including recorded as such as NaN).

func (*NetData) SaveJSON

func (nd *NetData) SaveJSON(filename core.Filename) error

SaveJSON saves colors to a JSON-formatted file.

func (*NetData) SelectedUnitTable

func (nd *NetData) SelectedUnitTable(di int) *table.Table

SelectedUnitTable returns a table with all of the data for the currently-selected unit, and data parallel index.

func (*NetData) SendUnitValue

func (nd *NetData) SendUnitValue(laynm string, vnm string, uidx1d int) (float32, bool)

SendUnitVal returns the value for given layer, variable name, unit index, for sending pathway variable, based on recorded synaptic pathway data. Returns false if value unavailable for any reason (including recorded as such as NaN).

func (*NetData) UnitValRaster

func (nd *NetData) UnitValRaster(laynm string, vnm string, uidx1d int, rastCtr int, di int) (float32, bool)

UnitValRaster returns the value for given layer, variable name, unit index, and raster counter number. Returns false if value unavailable for any reason (including recorded as such as NaN).

func (*NetData) UnitValue

func (nd *NetData) UnitValue(laynm string, vnm string, uidx1d int, recno int, di int) (float32, bool)

UnitVal returns the value for given layer, variable name, unit index, data parallel idx di, and record number, which is -1 for current (last) record, or in [0..Len-1] for prior records. Returns false if value unavailable for any reason (including recorded as such as NaN).

func (*NetData) UnitValueIndex

func (nd *NetData) UnitValueIndex(laynm string, vnm string, uidx1d int, ridx int, di int) (float32, bool)

UnitValueIndex returns the value for given layer, variable name, unit index, stored idx, and data parallel index. Returns false if value unavailable for any reason (including recorded as such as NaN).

func (*NetData) UpdateUnVarRange

func (nd *NetData) UpdateUnVarRange()

UpdateUnVarRange updates the range for unit variables, integrating over the entire range of stored values, so it is valid when iterating over history.

func (*NetData) VarRange

func (nd *NetData) VarRange(vnm string) (float32, float32, bool)

VarRange returns the current min, max range for given variable. Returns false if not found or no data.

func (*NetData) WriteJSON

func (nd *NetData) WriteJSON(w io.Writer) error

WriteJSON writes netdata to JSON format

type NetView

type NetView struct {
	core.Frame

	// the network that we're viewing
	Net emer.Network `set:"-"`

	// current variable that we're viewing
	Var string `set:"-"`

	// current data parallel index di, for networks capable of processing input patterns in parallel.
	Di int

	// the list of variables to view
	Vars []string

	// list of synaptic variables
	SynVars []string

	// map of synaptic variable names to index
	SynVarsMap map[string]int

	// parameters for the list of variables to view
	VarOptions map[string]*VarOptions

	// current var params -- only valid during Update of display
	CurVarOptions *VarOptions `json:"-" xml:"-" display:"-"`

	// parameters controlling how the view is rendered
	Options Options

	// color map for mapping values to colors -- set by name in Options
	ColorMap *colormap.Map

	// color map value representing ColorMap
	ColorMapButton *core.ColorMapButton

	// record number to display -- use -1 to always track latest, otherwise in range
	RecNo int

	// last non-empty counters string provided -- re-used if no new one
	LastCtrs string

	// current counters
	CurCtrs string

	// contains all the network data with history
	Data NetData

	// mutex on data access
	DataMu sync.RWMutex `display:"-" copier:"-" json:"-" xml:"-"`
	// contains filtered or unexported fields
}

NetView is a Cogent Core Widget that provides a 3D network view using the Cogent Core gi3d 3D framework.

func NewNetView

func NewNetView(parent ...tree.Node) *NetView

NewNetView returns a new NetView with the given optional parent: NetView is a Cogent Core Widget that provides a 3D network view using the Cogent Core gi3d 3D framework.

func (*NetView) ConfigLabels

func (nv *NetView) ConfigLabels(labs []string) bool

ConfigLabels ensures that given label xyz.Text2D objects are created and initialized in a top-level group called Labels. Use LabelByName() to get a given label, and LayerByName() to get a Layer group, whose Pose can be copied to put a label in position relative to a layer. Default alignment is Left, Top. Returns true set of labels was changed (mods).

func (*NetView) Counters

func (nv *NetView) Counters() *core.Text

func (*NetView) Current

func (nv *NetView) Current()

Current records the current state of the network, including synaptic values, and updates the display. Use this when switching to NetView tab after network has been running while viewing another tab, because the network state is typically not recored then.

func (*NetView) GoUpdateView

func (nv *NetView) GoUpdateView()

GoUpdateView is the update call to make from another go routine it does the proper blocking to coordinate with GUI updates generated on the main GUI thread.

func (*NetView) HasLayers

func (nv *NetView) HasLayers() bool

HasLayers returns true if network has any layers -- else no display

func (*NetView) Init

func (nv *NetView) Init()

func (*NetView) IsViewingSynapse

func (nv *NetView) IsViewingSynapse() bool

IsViewingSynapse returns true if netview is viewing synapses.

func (*NetView) LabelByName

func (nv *NetView) LabelByName(lab string) *xyz.Text2D

LabelByName returns given Text2D label (see ConfigLabels). nil if not found.

func (*NetView) Labels

func (nv *NetView) Labels() *xyz.Group

func (*NetView) LayerByName

func (nv *NetView) LayerByName(lay string) *xyz.Group

LayerByName returns the xyz.Group that represents layer of given name. nil if not found.

func (*NetView) Layers

func (nv *NetView) Layers() *xyz.Group

func (*NetView) MakeToolbar

func (nv *NetView) MakeToolbar(p *tree.Plan)

func (*NetView) MakeViewbar

func (nv *NetView) MakeViewbar(p *tree.Plan)

func (*NetView) NetFrame

func (nv *NetView) NetFrame() *core.Frame

func (*NetView) NetVarsList

func (nv *NetView) NetVarsList(net emer.Network, layEven bool) (nvars, synvars []string)

NetVarsList returns the list of layer and path variables for given network. layEven ensures that the number of layer variables is an even number if true (used for display but not storage).

func (*NetView) OpenWeights

func (nv *NetView) OpenWeights(filename core.Filename)

OpenWeights opens the network weights.

func (*NetView) PlotSelectedUnit

func (nv *NetView) PlotSelectedUnit() (*table.Table, *plotcore.Editor)

PlotSelectedUnit opens a window with a plot of all the data for the currently selected unit, saving data to the tensorfs.CurRoot/NetView directory. Useful for replaying detailed trace for units of interest.

func (*NetView) ReadLock

func (nv *NetView) ReadLock()

ReadLock locks data for reading -- call ReadUnlock when done. Call this surrounding calls to UnitVal.

func (*NetView) ReadUnlock

func (nv *NetView) ReadUnlock()

ReadUnlock unlocks data for reading.

func (*NetView) RecBkwd

func (nv *NetView) RecBkwd() bool

RecBkwd move view record 1 steps backward. Returns true if updated.

func (*NetView) RecFastBkwd

func (nv *NetView) RecFastBkwd() bool

RecFastBkwd move view record N (default 10) steps backward. Returns true if updated.

func (*NetView) RecFastFwd

func (nv *NetView) RecFastFwd() bool

RecFastFwd move view record N (default 10) steps forward. Returns true if updated.

func (*NetView) RecFullBkwd

func (nv *NetView) RecFullBkwd() bool

RecFullBkwd move view record to start of history.

func (*NetView) RecFwd

func (nv *NetView) RecFwd() bool

RecFwd move view record 1 step forward. Returns true if updated.

func (*NetView) RecTrackLatest

func (nv *NetView) RecTrackLatest() bool

RecTrackLatest sets view to track latest record (-1). Returns true if updated.

func (*NetView) Record

func (nv *NetView) Record(counters string, rastCtr int)

Record records the current state of the network, along with provided counters string, which is displayed at the bottom of the view to show the current state of the counters. The rastCtr is the raster counter value used for the raster plot mode -- use -1 for a default incrementing counter. The NetView displays this recorded data when Update is next called.

func (*NetView) RecordCounters

func (nv *NetView) RecordCounters(counters string)

RecordCounters saves the counters, so they are available for a Current update

func (*NetView) RecordSyns

func (nv *NetView) RecordSyns()

RecordSyns records synaptic data -- stored separate from unit data and only needs to be called when synaptic values are updated. Should be done when the DWt values have been computed, before updating Wts and zeroing. NetView displays this recorded data when Update is next called.

func (*NetView) SaveWeights

func (nv *NetView) SaveWeights(filename core.Filename)

SaveWeights saves the network weights.

func (*NetView) SceneWidget

func (nv *NetView) SceneWidget() *Scene

func (*NetView) SceneXYZ

func (nv *NetView) SceneXYZ() *xyz.Scene

func (*NetView) SetColorMap

func (t *NetView) SetColorMap(v *colormap.Map) *NetView

SetColorMap sets the [NetView.ColorMap]: color map for mapping values to colors -- set by name in Options

func (*NetView) SetColorMapButton

func (t *NetView) SetColorMapButton(v *core.ColorMapButton) *NetView

SetColorMapButton sets the [NetView.ColorMapButton]: color map value representing ColorMap

func (*NetView) SetCounters

func (nv *NetView) SetCounters(ctrs string)

SetCounters sets the counters widget view display at bottom of netview

func (*NetView) SetCurCtrs

func (t *NetView) SetCurCtrs(v string) *NetView

SetCurCtrs sets the [NetView.CurCtrs]: current counters

func (*NetView) SetCurVarOptions

func (t *NetView) SetCurVarOptions(v *VarOptions) *NetView

SetCurVarOptions sets the [NetView.CurVarOptions]: current var params -- only valid during Update of display

func (*NetView) SetData

func (t *NetView) SetData(v NetData) *NetView

SetData sets the [NetView.Data]: contains all the network data with history

func (*NetView) SetDataMu

func (t *NetView) SetDataMu(v sync.RWMutex) *NetView

SetDataMu sets the [NetView.DataMu]: mutex on data access

func (*NetView) SetDi

func (t *NetView) SetDi(v int) *NetView

SetDi sets the [NetView.Di]: current data parallel index di, for networks capable of processing input patterns in parallel.

func (*NetView) SetLastCtrs

func (t *NetView) SetLastCtrs(v string) *NetView

SetLastCtrs sets the [NetView.LastCtrs]: last non-empty counters string provided -- re-used if no new one

func (*NetView) SetMaxRecs

func (nv *NetView) SetMaxRecs(max int)

SetMaxRecs sets the maximum number of records that are maintained (default 210) resets the current data in the process

func (*NetView) SetNet

func (nv *NetView) SetNet(net emer.Network)

SetNet sets the network to view and updates view

func (*NetView) SetOptions

func (t *NetView) SetOptions(v Options) *NetView

SetOptions sets the [NetView.Options]: parameters controlling how the view is rendered

func (*NetView) SetRecNo

func (t *NetView) SetRecNo(v int) *NetView

SetRecNo sets the [NetView.RecNo]: record number to display -- use -1 to always track latest, otherwise in range

func (*NetView) SetSynVars

func (t *NetView) SetSynVars(v ...string) *NetView

SetSynVars sets the [NetView.SynVars]: list of synaptic variables

func (*NetView) SetSynVarsMap

func (t *NetView) SetSynVarsMap(v map[string]int) *NetView

SetSynVarsMap sets the [NetView.SynVarsMap]: map of synaptic variable names to index

func (*NetView) SetVar

func (nv *NetView) SetVar(vr string)

SetVar sets the variable to view and updates the display

func (*NetView) SetVarOptions

func (t *NetView) SetVarOptions(v map[string]*VarOptions) *NetView

SetVarOptions sets the [NetView.VarOptions]: parameters for the list of variables to view

func (*NetView) SetVars

func (t *NetView) SetVars(v ...string) *NetView

SetVars sets the [NetView.Vars]: the list of variables to view

func (*NetView) ShowAllParams

func (nv *NetView) ShowAllParams() string

ShowAllParams shows a dialog of all the parameters in the network.

func (*NetView) ShowKeyLayerParams

func (nv *NetView) ShowKeyLayerParams() string

ShowKeyLayerParams shows a dialog with a listing for all layers in the network, of the most important layer-level params (specific to each algorithm)

func (*NetView) ShowKeyPathParams

func (nv *NetView) ShowKeyPathParams() string

ShowKeyPathParams shows a dialog with a listing for all Recv pathways in the network, of the most important pathway-level params (specific to each algorithm)

func (*NetView) ShowNonDefaultParams

func (nv *NetView) ShowNonDefaultParams() string

ShowNonDefaultParams shows a dialog of all the parameters that are not at their default values in the network. Useful for setting params.

func (*NetView) Toolbar

func (nv *NetView) Toolbar() *core.Toolbar

func (*NetView) UnitValColor

func (nv *NetView) UnitValColor(lay emer.Layer, idx1d int, raw float32, hasval bool) (scaled float32, clr color.RGBA)

UnitValColor returns the raw value, scaled value, and color representation for given unit of given layer. scaled is in range -1..1

func (*NetView) UnitValRaster

func (nv *NetView) UnitValRaster(lay emer.Layer, idx []int, rCtr int) (raw, scaled float32, clr color.RGBA, hasval bool)

UnitValRaster returns the raw value, scaled value, and color representation for given unit of given layer, and given raster counter index value (0..RasterMax) scaled is in range -1..1

func (*NetView) UnitValue

func (nv *NetView) UnitValue(lay emer.Layer, idx []int) (raw, scaled float32, clr color.RGBA, hasval bool)

UnitValue returns the raw value, scaled value, and color representation for given unit of given layer. scaled is in range -1..1

func (*NetView) UpdateImpl

func (nv *NetView) UpdateImpl()

UpdateImpl does the guts of updating -- backend for Update or GoUpdate

func (*NetView) UpdateLayers

func (nv *NetView) UpdateLayers()

UpdateLayers updates the layer display with any structural or current data changes. Very fast if no structural changes.

func (*NetView) UpdatePaths

func (nv *NetView) UpdatePaths()

UpdatePaths updates the path display. Only called when layers have structural changes.

func (*NetView) UpdateRecNo

func (nv *NetView) UpdateRecNo()

UpdateRecNo updates the record number viewing

func (*NetView) UpdateView

func (nv *NetView) UpdateView()

UpdateView updates the display based on last recorded state of network.

func (*NetView) VarsFrame

func (nv *NetView) VarsFrame() *core.Tabs

func (*NetView) VarsListUpdate

func (nv *NetView) VarsListUpdate()

VarsListUpdate updates the list of network variables

func (*NetView) ViewDefaults

func (nv *NetView) ViewDefaults(se *xyz.Scene)

ViewDefaults are the default 3D view params

func (*NetView) Viewbar

func (nv *NetView) Viewbar() *core.Toolbar

type Options

type Options struct {

	// whether to display the pathways between layers as arrows
	Paths bool

	// PathType has name(s) to display (space separated), for path arrows,
	// and when there are multiple pathways from the same layer.
	// Uses the parameter Class names in addition to type,
	// and case insensitive "contains" logic for each name.
	PathType string

	// width of the path arrows, in normalized units
	PathWidth float32 `min:"0.0001" max:".05" step:"0.001" default:"0.002"`

	// raster plot parameters
	Raster RasterOptions `display:"inline"`

	// do not record synapse level data -- turn this on for very large networks where recording the entire synaptic state would be prohibitive
	NoSynData bool

	// maximum number of records to store to enable rewinding through prior states
	MaxRecs int `min:"1"`

	// number of variable columns
	NVarCols int

	// size of a single unit, where 1 = full width and no space.. .9 default
	UnitSize float32 `min:"0.1" max:"1" step:"0.1" default:"0.9"`

	// size of the layer name labels -- entire network view is unit sized
	LayerNameSize float32 `min:"0.01" max:".1" step:"0.01" default:"0.05"`

	// name of color map to use
	ColorMap core.ColorMapName

	// opacity (0-1) of zero values -- greater magnitude values become increasingly opaque on either side of this minimum
	ZeroAlpha float32 `min:"0" max:"1" step:"0.1" default:"0.5"`

	// the number of records to jump for fast forward/backward
	NFastSteps int
}

Options holds parameters controlling how the view is rendered

func (*Options) Defaults

func (nv *Options) Defaults()

type PathData

type PathData struct {

	// name of sending layer
	Send string

	// name of recv layer
	Recv string

	// source pathway
	Path emer.Path

	// synaptic data, by variable in SynVars and number of data points
	SynData []float32
}

PathData holds display state for a pathway

func (*PathData) Alloc

func (pd *PathData) Alloc()

Alloc allocates SynData to hold number of variables * nsyn synapses. If already has capacity, nothing happens.

func (*PathData) RecordData

func (pd *PathData) RecordData(nd *NetData)

RecordData records synaptic data from given paths. must use sender or recv based depending on natural ordering.

type RasterOptions

type RasterOptions struct {

	// if true, show a raster plot over time, otherwise units
	On bool

	// if true, the raster counter (time) is plotted across the X axis -- otherwise the Z depth axis
	XAxis bool

	// maximum count for the counter defining the raster plot
	Max int

	// size of a single unit, where 1 = full width and no space.. 1 default
	UnitSize float32 `min:"0.1" max:"1" step:"0.1" default:"1"`

	// height multiplier for units, where 1 = full height.. 0.2 default
	UnitHeight float32 `min:"0.1" max:"1" step:"0.1" default:"0.2"`
}

RasterOptions holds parameters controlling the raster plot view

func (*RasterOptions) Defaults

func (nv *RasterOptions) Defaults()

type Scene

type Scene struct {
	xyzcore.Scene

	NetView *NetView
}

Scene is a Widget for managing the 3D Scene of the NetView

func NewScene

func NewScene(parent ...tree.Node) *Scene

NewScene returns a new Scene with the given optional parent: Scene is a Widget for managing the 3D Scene of the NetView

func (*Scene) Init

func (sw *Scene) Init()

func (*Scene) LayerLabelAtPoint

func (sw *Scene) LayerLabelAtPoint(pos image.Point) emer.Layer

func (*Scene) LayerUnitAtPoint

func (sw *Scene) LayerUnitAtPoint(pos image.Point) (lay emer.Layer, lx, ly, unIndex int)

func (*Scene) MouseDownEvent

func (sw *Scene) MouseDownEvent(e events.Event)

func (*Scene) PathAtPoint

func (sw *Scene) PathAtPoint(pos image.Point) emer.Path

func (*Scene) SetNetView

func (t *Scene) SetNetView(v *NetView) *Scene

SetNetView sets the [Scene.NetView]

func (*Scene) WidgetTooltip

func (sw *Scene) WidgetTooltip(pos image.Point) (string, image.Point)

type VarOptions

type VarOptions struct {

	// name of the variable
	Var string

	// keep Min - Max centered around 0, and use negative heights for units -- else use full min-max range for height (no negative heights)
	ZeroCtr bool

	// range to display
	Range minmax.Range32 `display:"inline"`

	// if not using fixed range, this is the actual range of data
	MinMax minmax.F32 `display:"inline"`
}

VarOptions holds parameters for display of each variable

func (*VarOptions) Defaults

func (vp *VarOptions) Defaults()

Defaults sets default values if otherwise not set

func (*VarOptions) SetProps

func (vp *VarOptions) SetProps(pstr string)

SetProps parses Go struct-tag style properties for variable and sets values accordingly for customized defaults

type ViewUpdate

type ViewUpdate struct {

	// View is the network view.
	View *NetView `display:"-"`

	// whether in testing mode -- can be set in advance to drive appropriate updating
	Testing bool `display:"-"`

	// text to display at the bottom of the view
	Text string `display:"-"`

	// toggles update of display on
	On bool

	// SkipInvis means do not record network data when the NetView is invisible.
	// This speeds up running when not visible, but the NetView display will
	// not show the current state when switching back to it.
	SkipInvis bool

	// at what time scale to update the display during training?
	Train etime.Times

	// at what time scale to update the display during testing?
	Test etime.Times
}

ViewUpdate manages time scales for updating the NetView

func (*ViewUpdate) Config

func (vu *ViewUpdate) Config(nv *NetView, train, test etime.Times)

Config configures for given NetView and default train, test times

func (*ViewUpdate) GetUpdateTime

func (vu *ViewUpdate) GetUpdateTime(testing bool) etime.Times

GetUpdateTime returns the relevant update time based on testing flag

func (*ViewUpdate) GoUpdate

func (vu *ViewUpdate) GoUpdate()

GoUpdate does an update if view is On, visible and active, including recording new data and driving update of display. This version is only for calling from a separate goroutine, not the main event loop (see also Update).

func (*ViewUpdate) IsCycleUpdating

func (vu *ViewUpdate) IsCycleUpdating() bool

IsCycleUpdating returns true if the view is updating at a cycle level, either from raster or literal cycle level.

func (*ViewUpdate) IsViewingSynapse

func (vu *ViewUpdate) IsViewingSynapse() bool

IsViewingSynapse returns true if netview is actively viewing synapses.

func (*ViewUpdate) RecordSyns

func (vu *ViewUpdate) RecordSyns()

RecordSyns records synaptic data -- stored separate from unit data and only needs to be called when synaptic values are updated. Should be done when the DWt values have been computed, before updating Wts and zeroing. NetView displays this recorded data when Update is next called.

func (*ViewUpdate) Update

func (vu *ViewUpdate) Update()

Update does an update if view is On, visible and active, including recording new data and driving update of display. This version is only for calling from the main event loop (see also GoUpdate).

func (*ViewUpdate) UpdateCycle

func (vu *ViewUpdate) UpdateCycle(cyc int)

UpdateCycle triggers an update at the Cycle (Millisecond) timescale, using given text to display at bottom of view

func (*ViewUpdate) UpdateCycleRaster

func (vu *ViewUpdate) UpdateCycleRaster(cyc int)

UpdateCycleRaster raster version of Cycle update

func (*ViewUpdate) UpdateTime

func (vu *ViewUpdate) UpdateTime(time etime.Times)

UpdateTime triggers an update at given timescale.

func (*ViewUpdate) UpdateWhenStopped

func (vu *ViewUpdate) UpdateWhenStopped()

UpdateWhenStopped does an update when the network updating was stopped either via stepping or hitting the stop button. This has different logic for the raster view vs. regular. This is only for calling from a separate goroutine, not the main event loop.

Jump to

Keyboard shortcuts

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