prjn

package
v1.4.31 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: BSD-3-Clause Imports: 13 Imported by: 172

README

Docs: GoDoc

See Wiki Params page for detailed docs.

Package prjn is a separate package for defining Patterns of connectivity between layers (i.e., the ProjectionSpecs from C++ emergent). This is done using a fully independent structure that only knows about the shapes of the two layers, and it returns a fully general bitmap representation of the pattern of connectivity between them.

The algorithm-specific leabra.Prjn code then uses these patterns to do all the nitty-gritty of connecting up neurons.

This makes the projection code much simpler compared to the ProjectionSpec in C++ emergent, which was involved in both creating the pattern and also all the complexity of setting up the actual connections themselves. This should be the last time any of those projection patterns need to be written (having re-written this code too many times in the C++ version as the details of memory allocations changed).

A Pattern maintains nothing about a specific projection -- it only has the parameters that are applied in creating a new pattern of connectivity, so it can be shared among any number of projections that need the same connectivity parameters.

All Patttern types have a New where is the type name, that creates a new instance of given pattern initialized with default values.

Individual Pattern types may have a Defaults() method to initialize default values, but it is not mandatory.

Topographic Weights

Some projections (e.g., Circle, PoolTile) support the generation of topographic weight patterns that can be used to set initial weights, or per-synapse scaling factors. The Pattern interface does not define any standard for how this done, as there are various possible approaches. Circle defines a method with a standard signature that can be called for each point in the pattern, while PoolTile has a lot more overhead per point and is thus more efficient to generate the whole set of weights to tensor, which can then be used.

It is recommended to have some kind of positive flag(s) for enabling the use of TopoWts -- the standard weight initialization methods, e.g., leabra.Network.InitWts, can then automatically do the correct thing for each type of standard projection -- custom ones outside of this standard set would need custom code..

Documentation

Overview

Package prjn is a separate package for defining patterns of connectivity between layers (i.e., the ProjectionSpecs from C++ emergent). This is done using a fully independent structure that *only* knows about the shapes of the two layers, and it returns a fully general bitmap representation of the pattern of connectivity between them.

The algorithm-specific leabra.Prjn code then uses these patterns to do all the nitty-gritty of connecting up neurons.

This makes the projection code *much* simpler compared to the ProjectionSpec in C++ emergent, which was involved in both creating the pattern and also all the complexity of setting up the actual connections themselves. This should be the *last* time any of those projection patterns need to be written (having re-written this code too many times in the C++ version as the details of memory allocations changed).

A Pattern maintains nothing about a specific projection -- it only has the parameters that are applied in creating a new pattern of connectivity, so it can be shared among any number of projections that need the same connectivity parameters.

All Patttern types have a New<Name> where <Name> is the type name, that creates a new instance of given pattern initialized with default values.

Individual Pattern types may have a Defaults() method to initialize default values, but it is not mandatory.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConsStringFull

func ConsStringFull(send, recv *etensor.Shape, cons *etensor.Bits) []byte

ConsStringFull returns a []byte string showing the pattern of connectivity. if perRecv is true then it displays the sending connections per each recv unit -- otherwise it shows the entire matrix as a 2D matrix

func ConsStringPerRecv

func ConsStringPerRecv(send, recv *etensor.Shape, cons *etensor.Bits) []byte

ConsStringPerRecv returns a []byte string showing the pattern of connectivity organized by receiving unit, showing the sending connections per each

func NewTensors

func NewTensors(send, recv *etensor.Shape) (sendn, recvn *etensor.Int32, cons *etensor.Bits)

NewTensors returns the tensors used for Connect method, based on layer sizes

Types

type Circle added in v1.0.0

type Circle struct {

	// radius of the circle, in units from center in sending layer
	Radius int `desc:"radius of the circle, in units from center in sending layer"`

	// starting offset in sending layer, for computing the corresponding sending center relative to given recv unit position
	Start evec.Vec2i `desc:"starting offset in sending layer, for computing the corresponding sending center relative to given recv unit position"`

	// scaling to apply to receiving unit position to compute sending center as function of recv unit position
	Scale mat32.Vec2 `desc:"scaling to apply to receiving unit position to compute sending center as function of recv unit position"`

	// auto-scale sending center positions as function of relative sizes of send and recv layers -- if Start is positive then assumes it is a border, subtracted from sending size
	AutoScale bool `` /* 178-byte string literal not displayed */

	// if true, connectivity wraps around edges
	Wrap bool `desc:"if true, connectivity wraps around edges"`

	// if true, this prjn should set gaussian topographic weights, according to following parameters
	TopoWts bool `desc:"if true, this prjn should set gaussian topographic weights, according to following parameters"`

	// gaussian sigma (width) as a proportion of the radius of the circle
	Sigma float32 `desc:"gaussian sigma (width) as a proportion of the radius of the circle"`

	// maximum weight value for GaussWts function -- multiplies values
	MaxWt float32 `desc:"maximum weight value for GaussWts function -- multiplies values"`

	// if true, and connecting layer to itself (self projection), then make a self-connection from unit to itself
	SelfCon bool `desc:"if true, and connecting layer to itself (self projection), then make a self-connection from unit to itself"`
}

Circle implements a circular pattern of connectivity between two layers where the center moves in proportion to receiver position with offset and multiplier factors, and a given radius is used (with wrap-around optionally). A corresponding Gaussian bump of TopoWts is available as well. Makes for a good center-surround connectivity pattern. 4D layers are automatically flattened to 2D for this connection.

func NewCircle added in v1.0.0

func NewCircle() *Circle

func (*Circle) Connect added in v1.0.0

func (cr *Circle) Connect(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)

func (*Circle) Defaults added in v1.0.0

func (cr *Circle) Defaults()

func (*Circle) GaussWts added in v1.0.0

func (cr *Circle) GaussWts(si, ri int, send, recv *etensor.Shape) float32

GaussWts returns gaussian weight value for given unit indexes in given send and recv layers according to Gaussian Sigma and MaxWt. Can be used for a Prjn.SetScalesFunc or SetWtsFunc

func (*Circle) Name added in v1.0.0

func (cr *Circle) Name() string

type Full

type Full struct {

	// if true, and connecting layer to itself (self projection), then make a self-connection from unit to itself
	SelfCon bool `desc:"if true, and connecting layer to itself (self projection), then make a self-connection from unit to itself"`
}

Full implements full all-to-all pattern of connectivity between two layers

func NewFull

func NewFull() *Full

func (*Full) Connect

func (fp *Full) Connect(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)

func (*Full) Name

func (fp *Full) Name() string

type GaussTopo added in v1.0.0

type GaussTopo struct {

	// use gaussian topographic weights / scaling values
	On bool `desc:"use gaussian topographic weights / scaling values"`

	// [def: 0.6] [viewif: On] gaussian sigma (width) in normalized units where entire distance across relevant dimension is 1.0 -- typical useful values range from .3 to 1.5, with .6 default
	Sigma float32 `` /* 189-byte string literal not displayed */

	// [viewif: On] wrap the gaussian around on other sides of the receptive field, with the closest distance being used -- this removes strict topography but ensures a more uniform distribution of weight values so edge units don't have weaker overall weights
	Wrap bool `` /* 258-byte string literal not displayed */

	// [def: 0.8,1] [viewif: On] proportion to move gaussian center relative to the position of the receiving unit within its pool: 1.0 = centers span the entire range of the receptive field.  Typically want to use 1.0 for Wrap = true, and 0.8 for false
	CtrMove float32 `` /* 251-byte string literal not displayed */
}

GaussTopo has parameters for Gaussian topographic weights or scaling factors

func (*GaussTopo) DefNoWrap added in v1.0.0

func (gt *GaussTopo) DefNoWrap()

DefNoWrap sets default no-wrap parameters (CtrMove = .8 instead of 1)

func (*GaussTopo) DefWrap added in v1.0.0

func (gt *GaussTopo) DefWrap()

DefWrap sets default wrap parameters (which are overall defaults): CtrMove = 1

func (*GaussTopo) Defaults added in v1.0.0

func (gt *GaussTopo) Defaults()

type OneToOne

type OneToOne struct {

	// number of recv connections to make (0 for entire size of recv layer)
	NCons int `desc:"number of recv connections to make (0 for entire size of recv layer)"`

	// starting unit index for sending connections
	SendStart int `desc:"starting unit index for sending connections"`

	// starting unit index for recv connections
	RecvStart int `desc:"starting unit index for recv connections"`
}

OneToOne implements point-to-point one-to-one pattern of connectivity between two layers

func NewOneToOne

func NewOneToOne() *OneToOne

func (*OneToOne) Connect

func (ot *OneToOne) Connect(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)

func (*OneToOne) Name

func (ot *OneToOne) Name() string

type Pattern

type Pattern interface {
	// Name returns the name of the pattern -- i.e., the "type" name of the actual pattern generatop
	Name() string

	// Connect connects layers with the given shapes, returning the pattern of connectivity
	// as a bits tensor with shape = recv + send shapes, using row-major ordering with outer-most
	// indexes first (i.e., for each recv unit, there is a full inner-level of sender bits).
	// The number of connections for each recv and each send unit are also returned in
	// recvn and send tensors, each the shape of send and recv respectively.
	// The same flag should be set to true if the send and recv layers are the same (i.e., a self-connection)
	// often there are some different options for such connections.
	Connect(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)
}

Pattern defines a pattern of connectivity between two layers. The pattern is stored efficiently using a bitslice tensor of binary values indicating presence or absence of connection between two items. A receiver-based organization is generally assumed but connectivity can go either way.

type PoolOneToOne

type PoolOneToOne struct {

	// number of recv pools to connect (0 for entire number of pools in recv layer)
	NPools int `desc:"number of recv pools to connect (0 for entire number of pools in recv layer)"`

	// starting pool index for sending connections
	SendStart int `desc:"starting pool index for sending connections"`

	// starting pool index for recv connections
	RecvStart int `desc:"starting pool index for recv connections"`
}

PoolOneToOne implements one-to-one connectivity between pools within layers. Pools are the outer-most two dimensions of a 4D layer shape. If either layer does not have pools, then if the number of individual units matches the number of pools in the other layer, those are connected one-to-one otherwise each pool connects to the entire set of other units. If neither is 4D, then it is equivalent to OneToOne.

func NewPoolOneToOne

func NewPoolOneToOne() *PoolOneToOne

func (*PoolOneToOne) Connect

func (ot *PoolOneToOne) Connect(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)

func (*PoolOneToOne) ConnectOneToOne

func (ot *PoolOneToOne) ConnectOneToOne(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)

copy of OneToOne.Connect

func (*PoolOneToOne) ConnectPools

func (ot *PoolOneToOne) ConnectPools(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)

ConnectPools is when both recv and send have pools

func (*PoolOneToOne) ConnectRecvPool

func (ot *PoolOneToOne) ConnectRecvPool(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)

ConnectRecvPool is when recv has pools but send doesn't

func (*PoolOneToOne) ConnectSendPool

func (ot *PoolOneToOne) ConnectSendPool(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)

ConnectSendPool is when send has pools but recv doesn't

func (*PoolOneToOne) Name

func (ot *PoolOneToOne) Name() string

type PoolRect added in v1.1.8

type PoolRect struct {

	// size of rectangle (of pools) in sending layer that each receiving unit receives from
	Size evec.Vec2i `desc:"size of rectangle (of pools) in sending layer that each receiving unit receives from"`

	// starting pool offset in sending layer, for computing the corresponding sending lower-left corner relative to given recv pool position
	Start evec.Vec2i `` /* 140-byte string literal not displayed */

	// scaling to apply to receiving pool osition to compute corresponding position in sending layer of the lower-left corner of rectangle
	Scale mat32.Vec2 `` /* 138-byte string literal not displayed */

	// auto-set the Scale as function of the relative pool sizes of send and recv layers (e.g., if sending layer is 2x larger than receiving, Scale = 2)
	AutoScale bool `` /* 152-byte string literal not displayed */

	// if true, use Round when applying scaling factor -- otherwise uses Floor which makes Scale work like a grouping factor -- e.g., .25 will effectively group 4 recv pools with same send position
	RoundScale bool `` /* 197-byte string literal not displayed */

	// if true, connectivity wraps around all edges if it would otherwise go off the edge -- if false, then edges are clipped
	Wrap bool `desc:"if true, connectivity wraps around all edges if it would otherwise go off the edge -- if false, then edges are clipped"`

	// if true, and connecting layer to itself (self projection), then make a self-connection from unit to itself
	SelfCon bool `desc:"if true, and connecting layer to itself (self projection), then make a self-connection from unit to itself"`

	// starting pool position in receiving layer -- if > 0 then pools below this starting point remain unconnected
	RecvStart evec.Vec2i `desc:"starting pool position in receiving layer -- if > 0 then pools below this starting point remain unconnected"`

	// number of pools in receiving layer to connect -- if 0 then all (remaining after RecvStart) are connected -- otherwise if < remaining then those beyond this point remain unconnected
	RecvN evec.Vec2i `` /* 187-byte string literal not displayed */
}

PoolRect implements a rectangular pattern of connectivity between two 4D layers, in terms of their pool-level shapes, where the lower-left corner moves in proportion to receiver pool position with offset and multiplier factors (with wrap-around optionally).

func NewPoolRect added in v1.1.8

func NewPoolRect() *PoolRect

func (*PoolRect) Connect added in v1.1.8

func (cr *PoolRect) Connect(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)

func (*PoolRect) Defaults added in v1.1.8

func (cr *PoolRect) Defaults()

func (*PoolRect) Name added in v1.1.8

func (cr *PoolRect) Name() string

type PoolSameUnit added in v1.1.7

type PoolSameUnit struct {

	// if true, and connecting layer to itself (self projection), then make a self-connection from unit to itself
	SelfCon bool `desc:"if true, and connecting layer to itself (self projection), then make a self-connection from unit to itself"`
}

PoolSameUnit connects a given unit to the unit at the same index across all the pools in a layer. Pools are the outer-most two dimensions of a 4D layer shape. This is most sensible when pools have same numbers of units in send and recv. This is typically used for lateral topography-inducing connectivity and can also serve to reduce a pooled layer down to a single pool. The logic works if either layer does not have pools. If neither is 4D, then it is equivalent to OneToOne.

func NewPoolSameUnit added in v1.1.7

func NewPoolSameUnit() *PoolSameUnit

func (*PoolSameUnit) Connect added in v1.1.7

func (ot *PoolSameUnit) Connect(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)

func (*PoolSameUnit) ConnectOneToOne added in v1.1.7

func (ot *PoolSameUnit) ConnectOneToOne(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)

copy of OneToOne.Connect

func (*PoolSameUnit) ConnectPools added in v1.1.7

func (ot *PoolSameUnit) ConnectPools(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)

ConnectPools is when both recv and send have pools

func (*PoolSameUnit) ConnectRecvPool added in v1.1.7

func (ot *PoolSameUnit) ConnectRecvPool(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)

ConnectRecvPool is when recv has pools but send doesn't

func (*PoolSameUnit) ConnectSendPool added in v1.1.7

func (ot *PoolSameUnit) ConnectSendPool(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)

ConnectSendPool is when send has pools but recv doesn't

func (*PoolSameUnit) Name added in v1.1.7

func (ot *PoolSameUnit) Name() string

type PoolTile added in v1.0.0

type PoolTile struct {

	// reciprocal topographic connectivity -- logic runs with recv <-> send -- produces symmetric back-projection or topo prjn when sending layer is larger than recv
	Recip bool `` /* 165-byte string literal not displayed */

	// size of receptive field tile, in terms of pools on the sending layer
	Size evec.Vec2i `desc:"size of receptive field tile, in terms of pools on the sending layer"`

	// how many pools to skip in tiling over sending layer -- typically 1/2 of Size
	Skip evec.Vec2i `desc:"how many pools to skip in tiling over sending layer -- typically 1/2 of Size"`

	// starting pool offset for lower-left corner of first receptive field in sending layer
	Start evec.Vec2i `desc:"starting pool offset for lower-left corner of first receptive field in sending layer"`

	// if true, pool coordinates wrap around sending shape -- otherwise truncated at edges, which can lead to assymmetries in connectivity etc
	Wrap bool `` /* 142-byte string literal not displayed */

	// gaussian topographic weights / scaling parameters for full receptive field width. multiplies any other factors present
	GaussFull GaussTopo `desc:"gaussian topographic weights / scaling parameters for full receptive field width. multiplies any other factors present"`

	// gaussian topographic weights / scaling parameters within individual sending pools (i.e., unit positions within their parent pool drive distance for gaussian) -- this helps organize / differentiate units more within pools, not just across entire receptive field. multiplies any other factors present
	GaussInPool GaussTopo `` /* 305-byte string literal not displayed */

	// sigmoidal topographic weights / scaling parameters for full receptive field width.  left / bottom half have increasing sigmoids, and second half decrease.  Multiplies any other factors present (only used if Gauss versions are not On!)
	SigFull SigmoidTopo `` /* 241-byte string literal not displayed */

	// sigmoidal topographic weights / scaling parameters within individual sending pools (i.e., unit positions within their parent pool drive distance for sigmoid) -- this helps organize / differentiate units more within pools, not just across entire receptive field. multiplies any other factors present  (only used if Gauss versions are not On!).  left / bottom half have increasing sigmoids, and second half decrease.
	SigInPool SigmoidTopo `` /* 421-byte string literal not displayed */

	// min..max range of topographic weight values to generate
	TopoRange minmax.F32 `desc:"min..max range of topographic weight values to generate "`
}

PoolTile implements tiled 2D connectivity between pools within layers, where a 2D rectangular receptive field (defined over pools, not units) is tiled across the sending layer pools, with specified level of overlap. Pools are the outer-most two dimensions of a 4D layer shape. 2D layers are assumed to have 1x1 pool. This is a standard form of convolutional connectivity, where pools are the filters and the outer dims are locations filtered. Various initial weight / scaling patterns are also available -- code must specifically apply these to the receptive fields.

func NewPoolTile added in v1.0.0

func NewPoolTile() *PoolTile

func NewPoolTileRecip added in v1.0.0

func NewPoolTileRecip(ff *PoolTile) *PoolTile

NewPoolTileRecip creates a new PoolTile that is a recip version of given ff feedforward one

func (*PoolTile) Connect added in v1.0.0

func (pt *PoolTile) Connect(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)

func (*PoolTile) ConnectRecip added in v1.0.0

func (pt *PoolTile) ConnectRecip(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)

func (*PoolTile) Defaults added in v1.0.0

func (pt *PoolTile) Defaults()

func (*PoolTile) GaussOff added in v1.1.4

func (pt *PoolTile) GaussOff()

GaussOff turns off gaussian weights

func (*PoolTile) HasTopoWts added in v1.1.12

func (pt *PoolTile) HasTopoWts() bool

HasTopoWts returns true if some form of topographic weight patterns are set

func (*PoolTile) Name added in v1.0.0

func (pt *PoolTile) Name() string

func (*PoolTile) TopoWts added in v1.0.0

func (pt *PoolTile) TopoWts(send, recv *etensor.Shape, wts *etensor.Float32) error

TopoWts sets values in given 4D or 6D tensor according to *Topo settings. wts is shaped with first 2 outer-most dims as Y, X of units within layer / pool of recv layer (these are units over which topography is defined) and remaing 2D or 4D is for receptive field Size by units within pool size for sending layer.

func (*PoolTile) TopoWtsGauss2D added in v1.1.4

func (pt *PoolTile) TopoWtsGauss2D(send, recv *etensor.Shape, wts *etensor.Float32) error

TopoWtsGauss2D sets values in given 4D tensor according to *Topo settings. wts is shaped with first 2 outer-most dims as Y, X of units within layer / pool of recv layer (these are units over which topography is defined) and remaing 2D is for sending layer size (2D = sender)

func (*PoolTile) TopoWtsGauss4D added in v1.1.4

func (pt *PoolTile) TopoWtsGauss4D(send, recv *etensor.Shape, wts *etensor.Float32) error

TopoWtsGauss4D sets values in given 6D tensor according to *Topo settings. wts is shaped with first 2 outer-most dims as Y, X of units within layer / pool of recv layer (these are units over which topography is defined) and remaing 4D is for receptive field Size by units within pool size for sending layer.

func (*PoolTile) TopoWtsSigmoid2D added in v1.1.4

func (pt *PoolTile) TopoWtsSigmoid2D(send, recv *etensor.Shape, wts *etensor.Float32) error

TopoWtsSigmoid2D sets values in given 4D tensor according to Topo settings. wts is shaped with first 2 outer-most dims as Y, X of units within pool of recv layer (these are units over which topography is defined) and remaing 2D is for sending layer (2D = sender).

func (*PoolTile) TopoWtsSigmoid4D added in v1.1.4

func (pt *PoolTile) TopoWtsSigmoid4D(send, recv *etensor.Shape, wts *etensor.Float32) error

TopoWtsSigmoid4D sets values in given 6D tensor according to Topo settings. wts is shaped with first 2 outer-most dims as Y, X of units within pool of recv layer (these are units over which topography is defined) and remaing 2D is for receptive field Size by units within pool size for sending layer.

type PoolTileSub added in v1.1.30

type PoolTileSub struct {

	// reciprocal topographic connectivity -- logic runs with recv <-> send -- produces symmetric back-projection or topo prjn when sending layer is larger than recv
	Recip bool `` /* 165-byte string literal not displayed */

	// size of receptive field tile, in terms of pools on the sending layer
	Size evec.Vec2i `desc:"size of receptive field tile, in terms of pools on the sending layer"`

	// how many pools to skip in tiling over sending layer -- typically 1/2 of Size
	Skip evec.Vec2i `desc:"how many pools to skip in tiling over sending layer -- typically 1/2 of Size"`

	// starting pool offset for lower-left corner of first receptive field in sending layer
	Start evec.Vec2i `desc:"starting pool offset for lower-left corner of first receptive field in sending layer"`

	// number of sub-pools within each pool
	Subs evec.Vec2i `desc:"number of sub-pools within each pool"`

	// sending layer has sub-pools
	SendSubs bool `desc:"sending layer has sub-pools"`

	// if true, pool coordinates wrap around sending shape -- otherwise truncated at edges, which can lead to assymmetries in connectivity etc
	Wrap bool `` /* 142-byte string literal not displayed */

	// gaussian topographic weights / scaling parameters for full receptive field width. multiplies any other factors present
	GaussFull GaussTopo `desc:"gaussian topographic weights / scaling parameters for full receptive field width. multiplies any other factors present"`

	// gaussian topographic weights / scaling parameters within individual sending pools (i.e., unit positions within their parent pool drive distance for gaussian) -- this helps organize / differentiate units more within pools, not just across entire receptive field. multiplies any other factors present
	GaussInPool GaussTopo `` /* 305-byte string literal not displayed */

	// sigmoidal topographic weights / scaling parameters for full receptive field width.  left / bottom half have increasing sigmoids, and second half decrease.  Multiplies any other factors present (only used if Gauss versions are not On!)
	SigFull SigmoidTopo `` /* 241-byte string literal not displayed */

	// sigmoidal topographic weights / scaling parameters within individual sending pools (i.e., unit positions within their parent pool drive distance for sigmoid) -- this helps organize / differentiate units more within pools, not just across entire receptive field. multiplies any other factors present  (only used if Gauss versions are not On!).  left / bottom half have increasing sigmoids, and second half decrease.
	SigInPool SigmoidTopo `` /* 421-byte string literal not displayed */

	// min..max range of topographic weight values to generate
	TopoRange minmax.F32 `desc:"min..max range of topographic weight values to generate "`
}

PoolTileSub implements tiled 2D connectivity between pools within layers, where a 2D rectangular receptive field (defined over pools, not units) is tiled across the sending layer pools, with specified level of overlap. Pools are the outer-most two dimensions of a 4D layer shape. Sub version has sub-pools within each pool to encourage more independent representations. 2D layers are assumed to have 1x1 pool. This is a standard form of convolutional connectivity, where pools are the filters and the outer dims are locations filtered. Various initial weight / scaling patterns are also available -- code must specifically apply these to the receptive fields.

func NewPoolTileSub added in v1.1.30

func NewPoolTileSub() *PoolTileSub

func NewPoolTileSubRecip added in v1.1.30

func NewPoolTileSubRecip(ff *PoolTileSub) *PoolTileSub

NewPoolTileSubRecip creates a new PoolTileSub that is a recip version of given ff feedforward one

func (*PoolTileSub) Connect added in v1.1.30

func (pt *PoolTileSub) Connect(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)

func (*PoolTileSub) ConnectRecip added in v1.1.30

func (pt *PoolTileSub) ConnectRecip(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)

func (*PoolTileSub) Defaults added in v1.1.30

func (pt *PoolTileSub) Defaults()

func (*PoolTileSub) GaussOff added in v1.1.30

func (pt *PoolTileSub) GaussOff()

GaussOff turns off gaussian weights

func (*PoolTileSub) HasTopoWts added in v1.1.30

func (pt *PoolTileSub) HasTopoWts() bool

HasTopoWts returns true if some form of topographic weight patterns are set

func (*PoolTileSub) Name added in v1.1.30

func (pt *PoolTileSub) Name() string

func (*PoolTileSub) TopoWts added in v1.1.30

func (pt *PoolTileSub) TopoWts(send, recv *etensor.Shape, wts *etensor.Float32) error

TopoWts sets values in given 4D or 6D tensor according to *Topo settings. wts is shaped with first 2 outer-most dims as Y, X of units within layer / pool of recv layer (these are units over which topography is defined) and remaing 2D or 4D is for receptive field Size by units within pool size for sending layer.

func (*PoolTileSub) TopoWtsGauss2D added in v1.1.30

func (pt *PoolTileSub) TopoWtsGauss2D(send, recv *etensor.Shape, wts *etensor.Float32) error

TopoWtsGauss2D sets values in given 4D tensor according to *Topo settings. wts is shaped with first 2 outer-most dims as Y, X of units within layer / pool of recv layer (these are units over which topography is defined) and remaing 2D is for sending layer size (2D = sender)

func (*PoolTileSub) TopoWtsGauss4D added in v1.1.30

func (pt *PoolTileSub) TopoWtsGauss4D(send, recv *etensor.Shape, wts *etensor.Float32) error

TopoWtsGauss4D sets values in given 6D tensor according to *Topo settings. wts is shaped with first 2 outer-most dims as Y, X of units within layer / pool of recv layer (these are units over which topography is defined) and remaing 4D is for receptive field Size by units within pool size for sending layer.

func (*PoolTileSub) TopoWtsSigmoid2D added in v1.1.30

func (pt *PoolTileSub) TopoWtsSigmoid2D(send, recv *etensor.Shape, wts *etensor.Float32) error

TopoWtsSigmoid2D sets values in given 4D tensor according to Topo settings. wts is shaped with first 2 outer-most dims as Y, X of units within pool of recv layer (these are units over which topography is defined) and remaing 2D is for sending layer (2D = sender).

func (*PoolTileSub) TopoWtsSigmoid4D added in v1.1.30

func (pt *PoolTileSub) TopoWtsSigmoid4D(send, recv *etensor.Shape, wts *etensor.Float32) error

TopoWtsSigmoid4D sets values in given 6D tensor according to Topo settings. wts is shaped with first 2 outer-most dims as Y, X of units within pool of recv layer (these are units over which topography is defined) and remaing 2D is for receptive field Size by units within pool size for sending layer.

type PoolUnifRnd added in v1.0.7

type PoolUnifRnd struct {
	PoolOneToOne
	UnifRnd
}

PoolUnifRnd implements random pattern of connectivity between pools within layers. Pools are the outer-most two dimensions of a 4D layer shape. If either layer does not have pools, PoolUnifRnd works as UnifRnd does. If probability of connection (PCon) is 1, PoolUnifRnd works as PoolOnetoOne does.

func NewPoolUnifRnd added in v1.0.7

func NewPoolUnifRnd() *PoolUnifRnd

func (*PoolUnifRnd) Connect added in v1.0.7

func (ur *PoolUnifRnd) Connect(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)

func (*PoolUnifRnd) ConnectPoolsRnd added in v1.0.7

func (ur *PoolUnifRnd) ConnectPoolsRnd(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)

ConnectPoolsRnd is when both recv and send have pools

func (*PoolUnifRnd) ConnectRnd added in v1.0.7

func (ur *PoolUnifRnd) ConnectRnd(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)

ConnectRnd is a copy of UnifRnd.Connect with initial if statement modified

func (*PoolUnifRnd) Name added in v1.0.7

func (ur *PoolUnifRnd) Name() string

type Rect added in v1.0.0

type Rect struct {

	// size of rectangle in sending layer that each receiving unit receives from
	Size evec.Vec2i `desc:"size of rectangle in sending layer that each receiving unit receives from"`

	// starting offset in sending layer, for computing the corresponding sending lower-left corner relative to given recv unit position
	Start evec.Vec2i `` /* 135-byte string literal not displayed */

	// scaling to apply to receiving unit position to compute corresponding position in sending layer of the lower-left corner of rectangle
	Scale mat32.Vec2 `` /* 139-byte string literal not displayed */

	// auto-set the Scale as function of the relative sizes of send and recv layers (e.g., if sending layer is 2x larger than receiving, Scale = 2)
	AutoScale bool `` /* 147-byte string literal not displayed */

	// if true, use Round when applying scaling factor -- otherwise uses Floor which makes Scale work like a grouping factor -- e.g., .25 will effectively group 4 recv units with same send position
	RoundScale bool `` /* 197-byte string literal not displayed */

	// if true, connectivity wraps around all edges if it would otherwise go off the edge -- if false, then edges are clipped
	Wrap bool `desc:"if true, connectivity wraps around all edges if it would otherwise go off the edge -- if false, then edges are clipped"`

	// if true, and connecting layer to itself (self projection), then make a self-connection from unit to itself
	SelfCon bool `desc:"if true, and connecting layer to itself (self projection), then make a self-connection from unit to itself"`

	// make the reciprocal of the specified connections -- i.e., symmetric for swapping recv and send
	Recip bool `desc:"make the reciprocal of the specified connections -- i.e., symmetric for swapping recv and send"`

	// starting position in receiving layer -- if > 0 then units below this starting point remain unconnected
	RecvStart evec.Vec2i `desc:"starting position in receiving layer -- if > 0 then units below this starting point remain unconnected"`

	// number of units in receiving layer to connect -- if 0 then all (remaining after RecvStart) are connected -- otherwise if < remaining then those beyond this point remain unconnected
	RecvN evec.Vec2i `` /* 187-byte string literal not displayed */
}

Rect implements a rectangular pattern of connectivity between two layers where the lower-left corner moves in proportion to receiver position with offset and multiplier factors (with wrap-around optionally). 4D layers are automatically flattened to 2D for this projection.

func NewRect added in v1.0.0

func NewRect() *Rect

func NewRectRecip added in v1.3.27

func NewRectRecip(ff *Rect) *Rect

NewRectRecip creates a new Rect that is a Recip version of given ff one

func (*Rect) Connect added in v1.0.0

func (cr *Rect) Connect(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)

func (*Rect) ConnectRecip added in v1.3.27

func (cr *Rect) ConnectRecip(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)

func (*Rect) Defaults added in v1.0.0

func (cr *Rect) Defaults()

func (*Rect) Name added in v1.0.0

func (cr *Rect) Name() string

type SigmoidTopo added in v1.1.4

type SigmoidTopo struct {

	// use gaussian topographic weights / scaling values
	On bool `desc:"use gaussian topographic weights / scaling values"`

	// [viewif: On] gain of sigmoid that determines steepness of curve, in normalized units where entire distance across relevant dimension is 1.0 -- typical useful values range from 0.01 to 0.1
	Gain float32 `` /* 193-byte string literal not displayed */

	// [def: 0.5,1] [viewif: On] proportion to move gaussian center relative to the position of the receiving unit within its pool: 1.0 = centers span the entire range of the receptive field.  Typically want to use 1.0 for Wrap = true, and 0.8 for false
	CtrMove float32 `` /* 251-byte string literal not displayed */
}

SigmoidTopo has parameters for Gaussian topographic weights or scaling factors

func (*SigmoidTopo) Defaults added in v1.1.4

func (gt *SigmoidTopo) Defaults()

type UnifRnd added in v1.0.0

type UnifRnd struct {

	// [min: 0] [max: 1] probability of connection (0-1)
	PCon float32 `min:"0" max:"1" desc:"probability of connection (0-1)"`

	// if true, and connecting layer to itself (self projection), then make a self-connection from unit to itself
	SelfCon bool `desc:"if true, and connecting layer to itself (self projection), then make a self-connection from unit to itself"`

	// reciprocal connectivity: if true, switch the sending and receiving layers to create a symmetric top-down projection -- ESSENTIAL to use same RndSeed between two prjns to ensure symmetry
	Recip bool `` /* 192-byte string literal not displayed */

	// [view: -] random number source -- is created with its own separate source if nil
	Rand erand.Rand `view:"-" desc:"random number source -- is created with its own separate source if nil"`

	// [view: -] the current random seed -- will be initialized to a new random number from the global random stream when Rand is created.
	RndSeed int64 `` /* 137-byte string literal not displayed */
}

UnifRnd implements uniform random pattern of connectivity between two layers using a permuted (shuffled) list for without-replacement randomness, and maintains its own local random number source and seed which are initialized if Rand == nil -- usually best to keep this specific to each instance of a projection so it is fully reproducible and doesn't interfere with other random number streams.

func NewUnifRnd added in v1.0.0

func NewUnifRnd() *UnifRnd

func (*UnifRnd) Connect added in v1.0.0

func (ur *UnifRnd) Connect(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)

func (*UnifRnd) ConnectFull added in v1.0.0

func (ur *UnifRnd) ConnectFull(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)

func (*UnifRnd) ConnectRecip added in v1.0.6

func (ur *UnifRnd) ConnectRecip(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)

ConnectRecip does reciprocal connectvity

func (*UnifRnd) InitRand added in v1.3.48

func (ur *UnifRnd) InitRand()

func (*UnifRnd) Name added in v1.0.0

func (ur *UnifRnd) Name() string

Jump to

Keyboard shortcuts

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