etorch

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2022 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Version     = "v1.0.10"
	GitCommit   = "75bc2af"          // the commit JUST BEFORE the release
	VersionDate = "2022-02-15 13:06" // UTC
)

Variables

This section is empty.

Functions

func JsonToParams

func JsonToParams(b []byte) string

JsonToParams reformates json output to suitable params display output

Types

type Layer

type Layer struct {
	Network     emer.Network                `` /* 141-byte string literal not displayed */
	Nm          string                      `` /* 151-byte string literal not displayed */
	Cls         string                      `desc:"Class is for applying parameter styles, can be space separated multple tags"`
	Off         bool                        `desc:"inactivate this layer -- allows for easy experimentation"`
	Shp         etensor.Shape               `` /* 219-byte string literal not displayed */
	Typ         emer.LayerType              `` /* 161-byte string literal not displayed */
	Thr         int                         `` /* 216-byte string literal not displayed */
	Rel         relpos.Rel                  `view:"inline" desc:"Spatial relationship to other layer, determines positioning"`
	Ps          mat32.Vec3                  `` /* 154-byte string literal not displayed */
	Idx         int                         `desc:"a 0..n-1 index of the position of the layer within list of layers in the network."`
	RcvPrjns    emer.Prjns                  `desc:"list of receiving projections into this layer from other layers"`
	SndPrjns    emer.Prjns                  `desc:"list of sending projections from this layer to other layers"`
	States      map[string]*etensor.Float32 `desc:"map of states of the layer (activation, etc) -- name is variable name, tensor holds the data"`
	VarNamesMap map[string]int              `view:"-" desc:"map of variable names with index into the VarNames list"`
	VarNames    []string                    `view:"-" desc:"list of variable names alpha order"`
}

etorch.Layer manages the structural elements of the layer, which are common to any Layer type

func (*Layer) AddNetinActBiasVars

func (ly *Layer) AddNetinActBiasVars()

AddNetinActBiasVars adds standard Netin, Act, Bias variables

func (*Layer) AddVar

func (ly *Layer) AddVar(varNm string)

AddVar adds a variable to record in this layer. Each variable is recorded in a separate etensor.Float32, which is updated in python from torch tensors.

func (*Layer) AddVars

func (ly *Layer) AddVars(varNms []string)

AddVars adds variables to record in this layer. Each variable is recorded in a separate etensor.Float32, which is updated in python from torch tensors.

func (*Layer) AllParams

func (ly *Layer) AllParams() string

AllParams returns a listing of all parameters in the Layer

func (*Layer) ApplyParams

func (ly *Layer) ApplyParams(pars *params.Sheet, setMsg bool) (bool, error)

ApplyParams applies given parameter style Sheet to this layer and its recv projections. Calls UpdateParams on anything set to ensure derived parameters are all updated. 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. returns true if any params were set, and error if there were any errors.

func (*Layer) Build

func (ly *Layer) Build() error

Build constructs the layer state, including calling Build on the projections

func (*Layer) BuildPrjns

func (ly *Layer) BuildPrjns() error

BuildPrjns builds the projections, recv-side

func (*Layer) BuildVarNames

func (ly *Layer) BuildVarNames()

BuildVarNames makes the var names from VarNamesMap added previously

func (*Layer) Class

func (ly *Layer) Class() string

func (*Layer) Config

func (ly *Layer) Config(shape []int, typ emer.LayerType)

Config configures the basic properties of the layer

func (*Layer) Defaults

func (ly *Layer) Defaults()

func (*Layer) Idx4DFrom2D

func (ly *Layer) Idx4DFrom2D(x, y int) ([]int, bool)

func (*Layer) Index

func (ly *Layer) Index() int

func (*Layer) InitName

func (ly *Layer) InitName(lay emer.Layer, name string, net emer.Network)

InitName MUST be called to initialize the layer's pointer to itself as an emer.Layer which enables the proper interface methods to be called. Also sets the name, and the parent network that this layer belongs to (which layers may want to retain).

func (*Layer) Is2D

func (ly *Layer) Is2D() bool

func (*Layer) Is4D

func (ly *Layer) Is4D() bool

func (*Layer) IsOff

func (ly *Layer) IsOff() bool

func (*Layer) Label

func (ly *Layer) Label() string

func (*Layer) NPools

func (ly *Layer) NPools() int

NPools returns the number of unit sub-pools according to the shape parameters. Currently supported for a 4D shape, where the unit pools are the first 2 Y,X dims and then the units within the pools are the 2nd 2 Y,X dims

func (*Layer) NRecvPrjns

func (ly *Layer) NRecvPrjns() int

func (*Layer) NSendPrjns

func (ly *Layer) NSendPrjns() int

func (*Layer) Name

func (ly *Layer) Name() string

func (*Layer) NonDefaultParams

func (ly *Layer) NonDefaultParams() string

NonDefaultParams returns a listing of all parameters in the Layer that are not at their default values -- useful for setting param styles etc.

func (*Layer) Pos

func (ly *Layer) Pos() mat32.Vec3

func (*Layer) ReadWtsJSON

func (ly *Layer) ReadWtsJSON(r io.Reader) error

ReadWtsJSON reads the weights from this layer from the receiver-side perspective in a JSON text format. This is for a set of weights that were saved *for one layer only* and is not used for the network-level ReadWtsJSON, which reads into a separate structure -- see SetWts method.

func (*Layer) RecipToSendPrjn

func (ly *Layer) RecipToSendPrjn(spj emer.Prjn) (emer.Prjn, bool)

RecipToSendPrjn finds the reciprocal projection relative to the given sending projection found within the SendPrjns of this layer. This is then a recv prjn within this layer:

S=A -> R=B recip: R=A <- S=B -- ly = A -- we are the sender of srj and recv of rpj.

returns false if not found.

func (*Layer) RecvPrjn

func (ly *Layer) RecvPrjn(idx int) emer.Prjn

func (*Layer) RecvPrjnVals

func (ly *Layer) RecvPrjnVals(vals *[]float32, varNm string, sendLay emer.Layer, sendIdx1D int, prjnType string) error

RecvPrjnVals fills in values of given synapse variable name, for projection into given sending layer and neuron 1D index, for all receiving neurons in this layer, into given float32 slice (only resized if not big enough). prjnType is the string representation of the prjn type -- used if non-empty, useful when there are multiple projections between two layers. Returns error on invalid var name. If the receiving neuron is not connected to the given sending layer or neuron then the value is set to mat32.NaN(). Returns error on invalid var name or lack of recv prjn (vals always set to nan on prjn err).

func (*Layer) RecvPrjns

func (ly *Layer) RecvPrjns() *emer.Prjns

func (*Layer) RelPos

func (ly *Layer) RelPos() relpos.Rel

func (*Layer) SendPrjn

func (ly *Layer) SendPrjn(idx int) emer.Prjn

func (*Layer) SendPrjnVals

func (ly *Layer) SendPrjnVals(vals *[]float32, varNm string, recvLay emer.Layer, recvIdx1D int, prjnType string) error

SendPrjnVals fills in values of given synapse variable name, for projection into given receiving layer and neuron 1D index, for all sending neurons in this layer, into given float32 slice (only resized if not big enough). prjnType is the string representation of the prjn type -- used if non-empty, useful when there are multiple projections between two layers. Returns error on invalid var name. If the sending neuron is not connected to the given receiving layer or neuron then the value is set to mat32.NaN(). Returns error on invalid var name or lack of recv prjn (vals always set to nan on prjn err).

func (*Layer) SendPrjns

func (ly *Layer) SendPrjns() *emer.Prjns

func (*Layer) SetClass

func (ly *Layer) SetClass(cls string)

func (*Layer) SetIndex

func (ly *Layer) SetIndex(idx int)

func (*Layer) SetName

func (ly *Layer) SetName(nm string)

func (*Layer) SetOff

func (ly *Layer) SetOff(off bool)

func (*Layer) SetPos

func (ly *Layer) SetPos(pos mat32.Vec3)

func (*Layer) SetRelPos

func (ly *Layer) SetRelPos(rel relpos.Rel)

func (*Layer) SetShape

func (ly *Layer) SetShape(shape []int)

SetShape sets the layer shape and also uses default dim names

func (*Layer) SetThread

func (ly *Layer) SetThread(thr int)

func (*Layer) SetType

func (ly *Layer) SetType(typ emer.LayerType)

func (*Layer) SetWts

func (ly *Layer) SetWts(lw *weights.Layer) error

SetWts sets the weights for this layer from weights.Layer decoded values

func (*Layer) Shape

func (ly *Layer) Shape() *etensor.Shape

func (*Layer) Size

func (ly *Layer) Size() mat32.Vec2

func (*Layer) Thread

func (ly *Layer) Thread() int

func (*Layer) Type

func (ly *Layer) Type() emer.LayerType

func (*Layer) TypeName

func (ly *Layer) TypeName() string

func (*Layer) UnitVal

func (ly *Layer) UnitVal(varNm string, idx []int) float32

UnitVal returns value of given variable name on given unit, using shape-based dimensional index

func (*Layer) UnitVal1D

func (ly *Layer) UnitVal1D(varIdx int, idx int) float32

UnitVal1D returns value of given variable index on given unit, using 1-dimensional index. returns NaN on invalid index. This is the core unit var access method used by other methods, so it is the only one that needs to be updated for derived layer types.

func (*Layer) UnitVals

func (ly *Layer) UnitVals(vals *[]float32, varNm string) error

UnitVals fills in values of given variable name on unit, for each unit in the layer, into given float32 slice (only resized if not big enough). Returns error on invalid var name.

func (*Layer) UnitValsTensor

func (ly *Layer) UnitValsTensor(tsr etensor.Tensor, varNm string) error

UnitValsTensor returns values of given variable name on unit for each unit in the layer, as a float32 tensor in same shape as layer units.

func (*Layer) UnitVarIdx

func (ly *Layer) UnitVarIdx(varNm string) (int, error)

UnitVarIdx returns the index of given variable within the Neuron, according to *this layer's* UnitVarNames() list (using a map to lookup index), or -1 and error message if not found.

func (*Layer) UnitVarNames

func (ly *Layer) UnitVarNames() []string

UnitVarNames returns a list of variable names available on the units in this layer

func (*Layer) UnitVarNum

func (ly *Layer) UnitVarNum() int

UnitVarNum returns the number of Neuron-level variables for this layer. This is needed for extending indexes in derived types.

func (*Layer) UnitVarProps

func (ly *Layer) UnitVarProps() map[string]string

UnitVarProps returns properties for variables

func (*Layer) UpdateParams

func (ly *Layer) UpdateParams()

UpdateParams updates all params given any changes that might have been made to individual values including those in the receiving projections of this layer

func (*Layer) VarRange

func (ly *Layer) VarRange(varNm string) (min, max float32, err error)

VarRange returns the min / max values for given variable todo: support r. s. projection values

func (*Layer) WriteWtsJSON

func (ly *Layer) WriteWtsJSON(w io.Writer, depth int)

WriteWtsJSON writes the weights from this layer from the receiver-side perspective in a JSON text format. We build in the indentation logic to make it much faster and more efficient.

type Network

type Network struct {
	EmerNet         emer.Network          `` /* 274-byte string literal not displayed */
	Nm              string                `desc:"overall name of network -- helps discriminate if there are multiple"`
	Layers          emer.Layers           `desc:"list of layers"`
	LayMap          map[string]emer.Layer `view:"-" desc:"map of name to layers -- layer names must be unique"`
	LayClassMap     map[string][]string   `view:"-" desc:"map of layer classes -- made during Build"`
	MinPos          mat32.Vec3            `view:"-" desc:"minimum display position in network"`
	MaxPos          mat32.Vec3            `view:"-" desc:"maximum display position in network"`
	MetaData        map[string]string     `` /* 194-byte string literal not displayed */
	LayVarNamesMap  map[string]int        `view:"-" desc:"map of variable names accumulated across layers, with index into the LayVarNames list"`
	LayVarNames     []string              `view:"-" desc:"list of variable names accumulated across layers, alpha order"`
	PrjnVarNamesMap map[string]int        `view:"-" desc:"map of variable names accumulated across prjns, with index into the LayVarNames list"`
	PrjnVarNames    []string              `view:"-" desc:"list of variable names accumulated across prjns, alpha order"`
}

etorch.Network holds the layers of the network

func (*Network) AddLayer

func (nt *Network) AddLayer(name string, shape []int, typ emer.LayerType) emer.Layer

AddLayer adds a new layer with given name and shape to the network. 2D and 4D layer shapes are generally preferred but not essential -- see AddLayer2D and 4D for convenience methods for those. 4D layers enable pool (unit-group) level inhibition in Etorch networks, for example. shape is in row-major format with outer-most dimensions first: e.g., 4D 3, 2, 4, 5 = 3 rows (Y) of 2 cols (X) of pools, with each unit group having 4 rows (Y) of 5 (X) units.

func (*Network) AddLayer2D

func (nt *Network) AddLayer2D(name string, shapeY, shapeX int, typ emer.LayerType) emer.Layer

AddLayer2D adds a new layer with given name and 2D shape to the network. 2D and 4D layer shapes are generally preferred but not essential.

func (*Network) AddLayer4D

func (nt *Network) AddLayer4D(name string, nPoolsY, nPoolsX, nNeurY, nNeurX int, typ emer.LayerType) emer.Layer

AddLayer4D adds a new layer with given name and 4D shape to the network. 4D layers enable pool (unit-group) level inhibition in Etorch networks, for example. shape is in row-major format with outer-most dimensions first: e.g., 4D 3, 2, 4, 5 = 3 rows (Y) of 2 cols (X) of pools, with each pool having 4 rows (Y) of 5 (X) neurons.

func (*Network) AddLayerInit

func (nt *Network) AddLayerInit(ly emer.Layer, name string, shape []int, typ emer.LayerType)

AddLayerInit is implementation routine that takes a given layer and adds it to the network, and initializes and configures it properly.

func (*Network) AllParams

func (nt *Network) AllParams() string

AllParams returns a listing of all parameters in the Network.

func (*Network) ApplyParams

func (nt *Network) ApplyParams(pars *params.Sheet, setMsg bool) (bool, error)

ApplyParams applies given parameter style Sheet to layers and prjns in this network. Calls UpdateParams to ensure derived parameters are all updated. 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. returns true if any params were set, and error if there were any errors.

func (*Network) BidirConnectLayerNames

func (nt *Network) BidirConnectLayerNames(low, high string, pat prjn.Pattern) (lowlay, highlay emer.Layer, fwdpj, backpj emer.Prjn, err error)

BidirConnectLayerNames establishes bidirectional projections between two layers, referenced by name, with low = the lower layer that sends a Forward projection to the high layer, and receives a Back projection in the opposite direction. Returns error if not successful. Does not yet actually connect the units within the layers -- that requires Build.

func (*Network) BidirConnectLayers

func (nt *Network) BidirConnectLayers(low, high emer.Layer, pat prjn.Pattern) (fwdpj, backpj emer.Prjn)

BidirConnectLayers establishes bidirectional projections between two layers, with low = lower layer that sends a Forward projection to the high layer, and receives a Back projection in the opposite direction. Does not yet actually connect the units within the layers -- that requires Build.

func (*Network) BidirConnectLayersPy

func (nt *Network) BidirConnectLayersPy(low, high emer.Layer, pat prjn.Pattern)

BidirConnectLayersPy establishes bidirectional projections between two layers, with low = lower layer that sends a Forward projection to the high layer, and receives a Back projection in the opposite direction. Does not yet actually connect the units within the layers -- that requires Build. Py = python version with no return vals.

func (*Network) Bounds

func (nt *Network) Bounds() (min, max mat32.Vec3)

func (*Network) BoundsUpdt

func (nt *Network) BoundsUpdt()

BoundsUpdt updates the Min / Max display bounds for 3D display

func (*Network) Build

func (nt *Network) Build() error

Build constructs the layer and projection state based on the layer shapes and patterns of interconnectivity

func (*Network) BuildVarNames

func (nt *Network) BuildVarNames()

BuildVarNames makes the var names from states of network

func (*Network) ConnectLayerNames

func (nt *Network) ConnectLayerNames(send, recv string, pat prjn.Pattern, typ emer.PrjnType) (rlay, slay emer.Layer, pj emer.Prjn, err error)

ConnectLayerNames establishes a projection between two layers, referenced by name adding to the recv and send projection lists on each side of the connection. Returns error if not successful. Does not yet actually connect the units within the layers -- that requires Build.

func (*Network) ConnectLayers

func (nt *Network) ConnectLayers(send, recv emer.Layer, pat prjn.Pattern, typ emer.PrjnType) emer.Prjn

ConnectLayers establishes a projection between two layers, adding to the recv and send projection lists on each side of the connection. Does not yet actually connect the units within the layers -- that requires Build.

func (*Network) ConnectLayersPrjn

func (nt *Network) ConnectLayersPrjn(send, recv emer.Layer, pat prjn.Pattern, typ emer.PrjnType, pj emer.Prjn) emer.Prjn

ConnectLayersPrjn makes connection using given projection between two layers, adding given prjn to the recv and send projection lists on each side of the connection. Does not yet actually connect the units within the layers -- that requires Build.

func (*Network) Defaults

func (nt *Network) Defaults()

Defaults sets all the default parameters for all layers and projections

func (*Network) InitName

func (nt *Network) InitName(net emer.Network, name string)

InitName MUST be called to initialize the network's pointer to itself as an emer.Network which enables the proper interface methods to be called. Also sets the name.

func (*Network) Label

func (nt *Network) Label() string

func (*Network) LateralConnectLayer

func (nt *Network) LateralConnectLayer(lay emer.Layer, pat prjn.Pattern) emer.Prjn

LateralConnectLayer establishes a self-projection within given layer. Does not yet actually connect the units within the layers -- that requires Build.

func (*Network) LateralConnectLayerPrjn

func (nt *Network) LateralConnectLayerPrjn(lay emer.Layer, pat prjn.Pattern, pj emer.Prjn) emer.Prjn

LateralConnectLayerPrjn makes lateral self-projection using given projection. Does not yet actually connect the units within the layers -- that requires Build.

func (*Network) Layer

func (nt *Network) Layer(idx int) emer.Layer

func (*Network) LayerByName

func (nt *Network) LayerByName(name string) emer.Layer

LayerByName returns a layer by looking it up by name in the layer map (nil if not found). Will create the layer map if it is nil or a different size than layers slice, but otherwise needs to be updated manually.

func (*Network) LayerByNameTry

func (nt *Network) LayerByNameTry(name string) (emer.Layer, error)

LayerByNameTry returns a layer by looking it up by name -- emits a log error message if layer is not found

func (*Network) LayersByClass added in v1.0.10

func (nt *Network) LayersByClass(classes ...string) []string

LayersByClass returns a list of layer names by given class(es). Lists are compiled when network Build() function called. The layer Type is always included as a Class, along with any other space-separated strings specified in Class for parameter styling, etc. If no classes are passed, all layer names in order are returned.

func (*Network) Layout

func (nt *Network) Layout()

Layout computes the 3D layout of layers based on their relative position settings

func (*Network) MakeLayMap

func (nt *Network) MakeLayMap()

MakeLayMap updates layer map based on current layers

func (*Network) NLayers

func (nt *Network) NLayers() int

func (*Network) Name

func (nt *Network) Name() string

emer.Network interface methods:

func (*Network) NewLayer

func (nt *Network) NewLayer() emer.Layer

NewLayer returns new layer of proper type

func (*Network) NewPrjn

func (nt *Network) NewPrjn() emer.Prjn

NewPrjn returns new prjn of proper type

func (*Network) NonDefaultParams

func (nt *Network) NonDefaultParams() string

NonDefaultParams returns a listing of all parameters in the Network that are not at their default values -- useful for setting param styles etc.

func (*Network) OpenWtsJSON

func (nt *Network) OpenWtsJSON(filename gi.FileName) error

OpenWtsJSON opens network weights (and any other state that adapts with learning) from a JSON-formatted file. If filename has .gz extension, then file is gzip uncompressed.

func (*Network) ReadWtsJSON

func (nt *Network) ReadWtsJSON(r io.Reader) error

ReadWtsJSON reads network weights (and any other state that adapts with learning) from JSON-formatted input. Reads into a temporary weights.Network structure that is then passed to SetWts to actually set the weights.

func (*Network) SaveWtsJSON

func (nt *Network) SaveWtsJSON(filename gi.FileName) error

SaveWtsJSON saves network weights (and any other state that adapts with learning) to a JSON-formatted file. If filename has .gz extension, then file is gzip compressed.

func (*Network) SetWts

func (nt *Network) SetWts(nw *weights.Network) error

SetWts sets the weights for this network from weights.Network decoded values

func (*Network) StdVertLayout

func (nt *Network) StdVertLayout()

StdVertLayout arranges layers in a standard vertical (z axis stack) layout, by setting the Rel settings

func (*Network) SynVarNames

func (nt *Network) SynVarNames() []string

SynVarNames returns the names of all the variables on the synapses in this network. Not all projections need to support all variables, but must safely return 0's for unsupported ones. The order of this list determines NetView variable display order. This is typically a global list so do not modify!

func (*Network) SynVarProps

func (nt *Network) SynVarProps() map[string]string

SynVarProps returns properties for variables

func (*Network) UnitVarNames

func (nt *Network) UnitVarNames() []string

UnitVarNames returns a list of variable names available on the units in this network. Not all layers need to support all variables, but must safely return 0's for unsupported ones. The order of this list determines NetView variable display order. This is typically a global list so do not modify!

func (*Network) UnitVarProps

func (nt *Network) UnitVarProps() map[string]string

UnitVarProps returns properties for variables

func (*Network) UpdateParams

func (nt *Network) UpdateParams()

UpdateParams updates all the derived parameters if any have changed, for all layers and projections

func (*Network) VarRange

func (nt *Network) VarRange(varNm string) (min, max float32, err error)

VarRange returns the min / max values for given variable todo: support r. s. projection values

func (*Network) WriteWtsJSON

func (nt *Network) WriteWtsJSON(w io.Writer) error

WriteWtsJSON writes network weights (and any other state that adapts with learning) to JSON-formatted output.

type Prjn

type Prjn struct {
	Off         bool                        `desc:"inactivate this projection -- allows for easy experimentation"`
	Cls         string                      `desc:"Class is for applying parameter styles, can be space separated multple tags"`
	Notes       string                      `desc:"can record notes about this projection here"`
	Send        emer.Layer                  `desc:"sending layer for this projection"`
	Recv        emer.Layer                  `` /* 169-byte string literal not displayed */
	Pat         prjn.Pattern                `desc:"pattern of connectivity"`
	Typ         emer.PrjnType               `` /* 154-byte string literal not displayed */
	RConN       []int32                     `view:"-" desc:"number of recv connections for each neuron in the receiving layer, as a flat list"`
	RConNAvgMax minmax.AvgMax32             `inactive:"+" desc:"average and maximum number of recv connections in the receiving layer"`
	RConIdxSt   []int32                     `view:"-" desc:"starting index into ConIdx list for each neuron in receiving layer -- just a list incremented by ConN"`
	RConIdx     []int32                     `` /* 213-byte string literal not displayed */
	SSynIdx     []int32                     `` /* 182-byte string literal not displayed */
	SConN       []int32                     `view:"-" desc:"number of sending connections for each neuron in the sending layer, as a flat list"`
	SConNAvgMax minmax.AvgMax32             `inactive:"+" desc:"average and maximum number of sending connections in the sending layer"`
	SConIdxSt   []int32                     `view:"-" desc:"starting index into ConIdx list for each neuron in sending layer -- just a list incremented by ConN"`
	SConIdx     []int32                     `` /* 213-byte string literal not displayed */
	States      map[string]*etensor.Float32 `desc:"map of states of the projection (weights, etc) -- name is variable name, tensor holds the data"`
	VarNamesMap map[string]int              `view:"-" desc:"map of variable names with index into the VarNames list"`
	VarNames    []string                    `view:"-" desc:"list of variable names alpha order"`
}

Prjn contains the basic structural information for specifying a projection of synaptic connections between two layers, and maintaining all the synaptic connection-level data. The exact same struct object is added to the Recv and Send layers, and it manages everything about the connectivity, and methods on the Prjn handle all the relevant computation.

func (*Prjn) AddVar

func (pj *Prjn) AddVar(varNm string)

AddVar adds a variable to record in this layer. Each variable is recorded in a separate etensor.Float32, which is updated in python from torch tensors.

func (*Prjn) AddVars

func (pj *Prjn) AddVars(varNms []string)

AddVars adds variables to record in this layer. Each variable is recorded in a separate etensor.Float32, which is updated in python from torch tensors.

func (*Prjn) AddWtDWtVars

func (pj *Prjn) AddWtDWtVars()

AddWtDWtVars adds standard Wt, DWt variables

func (*Prjn) AllParams

func (pj *Prjn) AllParams() string

AllParams returns a listing of all parameters in the Layer

func (*Prjn) ApplyParams

func (pj *Prjn) ApplyParams(pars *params.Sheet, setMsg bool) (bool, error)

ApplyParams applies given parameter style Sheet to this projection. Calls UpdateParams if anything set to ensure derived parameters are all updated. 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. returns true if any params were set, and error if there were any errors.

func (*Prjn) Build

func (pj *Prjn) Build() error

Build constructs the full connectivity among the layers as specified in this projection. Calls PrjnStru.BuildStru and then allocates the synaptic values in Syns accordingly.

func (*Prjn) BuildStru

func (pj *Prjn) BuildStru() error

BuildStru constructs the full connectivity among the layers as specified in this projection. Calls Validate and returns false if invalid. Pat.Connect is called to get the pattern of the connection. Then the connection indexes are configured according to that pattern.

func (*Prjn) BuildVarNames

func (pj *Prjn) BuildVarNames()

BuildVarNames makes the var names from VarNamesMap added previously

func (*Prjn) Class

func (pj *Prjn) Class() string

func (*Prjn) Connect

func (pj *Prjn) Connect(slay, rlay emer.Layer, pat prjn.Pattern, typ emer.PrjnType)

Connect sets the connectivity between two layers and the pattern to use in interconnecting them

func (*Prjn) Defaults

func (pj *Prjn) Defaults()

func (*Prjn) Init

func (pj *Prjn) Init(prjn emer.Prjn)

Init MUST be called to initialize the prjn's pointer to itself as an emer.Prjn which enables the proper interface methods to be called.

func (*Prjn) IsOff

func (pj *Prjn) IsOff() bool

func (*Prjn) Label

func (pj *Prjn) Label() string

func (*Prjn) Name

func (pj *Prjn) Name() string

func (*Prjn) NonDefaultParams

func (pj *Prjn) NonDefaultParams() string

NonDefaultParams returns a listing of all parameters in the Layer that are not at their default values -- useful for setting param styles etc.

func (*Prjn) Pattern

func (pj *Prjn) Pattern() prjn.Pattern

func (*Prjn) PrjnTypeName

func (pj *Prjn) PrjnTypeName() string

func (*Prjn) ReadWtsJSON

func (pj *Prjn) ReadWtsJSON(r io.Reader) error

ReadWtsJSON reads the weights from this projection from the receiver-side perspective in a JSON text format. This is for a set of weights that were saved *for one prjn only* and is not used for the network-level ReadWtsJSON, which reads into a separate structure -- see SetWts method.

func (*Prjn) RecvLay

func (pj *Prjn) RecvLay() emer.Layer

func (*Prjn) SendLay

func (pj *Prjn) SendLay() emer.Layer

func (*Prjn) SetClass

func (pj *Prjn) SetClass(cls string) emer.Prjn

func (*Prjn) SetNIdxSt

func (pj *Prjn) SetNIdxSt(n *[]int32, avgmax *minmax.AvgMax32, idxst *[]int32, tn *etensor.Int32) int32

SetNIdxSt sets the *ConN and *ConIdxSt values given n tensor from Pat. Returns total number of connections for this direction.

func (*Prjn) SetOff

func (pj *Prjn) SetOff(off bool)

func (*Prjn) SetPattern

func (pj *Prjn) SetPattern(pat prjn.Pattern) emer.Prjn

func (*Prjn) SetSynVal

func (pj *Prjn) SetSynVal(varNm string, sidx, ridx int, val float32) error

SetSynVal sets value of given variable name on the synapse between given send, recv unit indexes (1D, flat indexes) returns error for access errors.

func (*Prjn) SetType

func (pj *Prjn) SetType(typ emer.PrjnType) emer.Prjn

func (*Prjn) SetWts

func (pj *Prjn) SetWts(pw *weights.Prjn) error

SetWts sets the weights for this projection from weights.Prjn decoded values

func (*Prjn) String

func (pj *Prjn) String() string

String satisfies fmt.Stringer for prjn

func (*Prjn) SynIdx

func (pj *Prjn) SynIdx(sidx, ridx int) int

SynIdx returns the index of the synapse between given send, recv unit indexes (1D, flat indexes). Returns -1 if synapse not found between these two neurons. Requires searching within connections for sending unit.

func (*Prjn) SynVal

func (pj *Prjn) SynVal(varNm string, sidx, ridx int) float32

SynVal returns value of given variable name on the synapse between given send, recv unit indexes (1D, flat indexes). Returns mat32.NaN() for access errors (see SynValTry for error message)

func (*Prjn) SynVal1D

func (pj *Prjn) SynVal1D(varIdx int, synIdx int) float32

SynVal1D returns value of given variable index (from SynVarIdx) on given SynIdx. Returns NaN on invalid index. This is the core synapse var access method used by other methods, so it is the only one that needs to be updated for derived layer types.

func (*Prjn) SynVals

func (pj *Prjn) SynVals(vals *[]float32, varNm string) error

SynVals sets values of given variable name for each synapse, using the natural ordering of the synapses (recv based) into given float32 slice (only resized if not big enough). Returns error on invalid var name.

func (*Prjn) SynVarIdx

func (pj *Prjn) SynVarIdx(varNm string) (int, error)

SynVarIdx returns the index of given variable within the synapse, according to *this prjn's* SynVarNames() list (using a map to lookup index), or -1 and error message if not found.

func (*Prjn) SynVarNames

func (pj *Prjn) SynVarNames() []string

func (*Prjn) SynVarNum

func (pj *Prjn) SynVarNum() int

SynVarNum returns the number of synapse-level variables for this prjn. This is needed for extending indexes in derived types.

func (*Prjn) SynVarProps

func (pj *Prjn) SynVarProps() map[string]string

SynVarProps returns properties for variables

func (*Prjn) Type

func (pj *Prjn) Type() emer.PrjnType

func (*Prjn) TypeName

func (pj *Prjn) TypeName() string

func (*Prjn) UpdateParams

func (pj *Prjn) UpdateParams()

UpdateParams updates all params given any changes that might have been made to individual values

func (*Prjn) Validate

func (pj *Prjn) Validate(logmsg bool) error

Validate tests for non-nil settings for the projection -- returns error message or nil if no problems (and logs them if logmsg = true)

func (*Prjn) WriteWtsJSON

func (pj *Prjn) WriteWtsJSON(w io.Writer, depth int)

WriteWtsJSON writes the weights from this projection from the receiver-side perspective in a JSON text format. We build in the indentation logic to make it much faster and more efficient.

Jump to

Keyboard shortcuts

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