prjn

package
v0.0.0-...-531e5d3 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2023 License: BSD-3-Clause Imports: 12 Imported by: 5

README

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.

Also, the Edge method is handy for dealing with edges and wrap-around etc.

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.

Also, the Edge method is handy for dealing with edges and wrap-around etc.

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 Edge

func Edge(ci, max int, wrap bool) (int, bool)

Edge returns coordinate value based on either wrapping or clipping at the edge and if not wrapping, if it should be clipped (ignored)

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

func WrapMinDist

func WrapMinDist(ci, max, ctr float32) float32

WrapMinDist returns the wrapped coordinate value that is closest to ctr i.e., if going out beyond max is closer, then returns that coordinate else if going below 0 is closer than not, then returns that coord

Types

type Circle

type Circle struct {
	Radius    int        `desc:"radius of the circle, in units from center in sending layer"`
	Start     evec.Vec2i `desc:"starting offset in sending layer, for computing the corresponding sending center relative to given recv unit position"`
	Scale     mat32.Vec2 `desc:"scaling to apply to receiving unit position to compute sending center as function of recv unit position"`
	AutoScale bool       `` /* 178-byte string literal not displayed */
	Wrap      bool       `desc:"if true, connectivity wraps around edges"`
	TopoWts   bool       `desc:"if true, this prjn should set gaussian topographic weights, according to following parameters"`
	Sigma     float32    `desc:"gaussian sigma (width) as a proportion of the radius of the circle"`
	MaxWt     float32    `desc:"maximum weight value for GaussWts function -- multiplies values"`
	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

func NewCircle() *Circle

func (*Circle) Connect

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

func (*Circle) Defaults

func (cr *Circle) Defaults()

func (*Circle) GaussWts

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

func (cr *Circle) Name() string

type Full

type Full struct {
	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

type GaussTopo struct {
	On      bool    `desc:"use gaussian topographic weights / scaling values"`
	Sigma   float32 `` /* 189-byte string literal not displayed */
	Wrap    bool    `` /* 258-byte string literal not displayed */
	CtrMove float32 `` /* 251-byte string literal not displayed */
}

GaussTopo has parameters for Gaussian topographic weights or scaling factors

func (*GaussTopo) DefNoWrap

func (gt *GaussTopo) DefNoWrap()

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

func (*GaussTopo) DefWrap

func (gt *GaussTopo) DefWrap()

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

func (*GaussTopo) Defaults

func (gt *GaussTopo) Defaults()

type OneToOne

type OneToOne struct {
	NCons     int `desc:"number of recv connections to make (0 for entire size of recv layer)"`
	SendStart int `desc:"starting unit index for sending 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 {
	NPools    int `desc:"number of recv pools to connect (0 for entire number of pools in recv layer)"`
	SendStart int `desc:"starting pool index for sending 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

type PoolRect struct {
	Size       evec.Vec2i `desc:"size of rectangle (of pools) in sending layer that each receiving unit receives from"`
	Start      evec.Vec2i `` /* 140-byte string literal not displayed */
	Scale      mat32.Vec2 `` /* 138-byte string literal not displayed */
	AutoScale  bool       `` /* 152-byte string literal not displayed */
	RoundScale bool       `` /* 197-byte string literal not displayed */
	Wrap       bool       `desc:"if true, connectivity wraps around all edges if it would otherwise go off the edge -- if false, then edges are clipped"`
	SelfCon    bool       `desc:"if true, and connecting layer to itself (self projection), then make a self-connection from unit to itself"`
	RecvStart  evec.Vec2i `desc:"starting pool position in receiving layer -- if > 0 then pools below this starting 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

func NewPoolRect() *PoolRect

func (*PoolRect) Connect

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

func (*PoolRect) Defaults

func (cr *PoolRect) Defaults()

func (*PoolRect) Name

func (cr *PoolRect) Name() string

type PoolSameUnit

type PoolSameUnit struct {
	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

func NewPoolSameUnit() *PoolSameUnit

func (*PoolSameUnit) Connect

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

func (*PoolSameUnit) ConnectOneToOne

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

copy of OneToOne.Connect

func (*PoolSameUnit) ConnectPools

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

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

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

func (ot *PoolSameUnit) Name() string

type PoolTile

type PoolTile struct {
	Recip       bool        `` /* 165-byte string literal not displayed */
	Size        evec.Vec2i  `desc:"size of receptive field tile, in terms of pools on the sending layer"`
	Skip        evec.Vec2i  `desc:"how many pools to skip in tiling over sending layer -- typically 1/2 of Size"`
	Start       evec.Vec2i  `desc:"starting pool offset for lower-left corner of first receptive field in sending layer"`
	Wrap        bool        `` /* 142-byte string literal not displayed */
	GaussFull   GaussTopo   `desc:"gaussian topographic weights / scaling parameters for full receptive field width. multiplies any other factors present"`
	GaussInPool GaussTopo   `` /* 305-byte string literal not displayed */
	SigFull     SigmoidTopo `` /* 241-byte string literal not displayed */
	SigInPool   SigmoidTopo `` /* 421-byte string literal not displayed */
	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

func NewPoolTile() *PoolTile

func NewPoolTileRecip

func NewPoolTileRecip(ff *PoolTile) *PoolTile

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

func (*PoolTile) Connect

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

func (*PoolTile) ConnectRecip

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

func (*PoolTile) Defaults

func (pt *PoolTile) Defaults()

func (*PoolTile) GaussOff

func (pt *PoolTile) GaussOff()

GaussOff turns off gaussian weights

func (*PoolTile) HasTopoWts

func (pt *PoolTile) HasTopoWts() bool

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

func (*PoolTile) Name

func (pt *PoolTile) Name() string

func (*PoolTile) TopoWts

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

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

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

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

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

type PoolTileSub struct {
	Recip       bool        `` /* 165-byte string literal not displayed */
	Size        evec.Vec2i  `desc:"size of receptive field tile, in terms of pools on the sending layer"`
	Skip        evec.Vec2i  `desc:"how many pools to skip in tiling over sending layer -- typically 1/2 of Size"`
	Start       evec.Vec2i  `desc:"starting pool offset for lower-left corner of first receptive field in sending layer"`
	Subs        evec.Vec2i  `desc:"number of sub-pools within each pool"`
	SendSubs    bool        `desc:"sending layer has sub-pools"`
	Wrap        bool        `` /* 142-byte string literal not displayed */
	GaussFull   GaussTopo   `desc:"gaussian topographic weights / scaling parameters for full receptive field width. multiplies any other factors present"`
	GaussInPool GaussTopo   `` /* 305-byte string literal not displayed */
	SigFull     SigmoidTopo `` /* 241-byte string literal not displayed */
	SigInPool   SigmoidTopo `` /* 421-byte string literal not displayed */
	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

func NewPoolTileSub() *PoolTileSub

func NewPoolTileSubRecip

func NewPoolTileSubRecip(ff *PoolTileSub) *PoolTileSub

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

func (*PoolTileSub) Connect

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

func (*PoolTileSub) ConnectRecip

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

func (*PoolTileSub) Defaults

func (pt *PoolTileSub) Defaults()

func (*PoolTileSub) GaussOff

func (pt *PoolTileSub) GaussOff()

GaussOff turns off gaussian weights

func (*PoolTileSub) HasTopoWts

func (pt *PoolTileSub) HasTopoWts() bool

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

func (*PoolTileSub) Name

func (pt *PoolTileSub) Name() string

func (*PoolTileSub) TopoWts

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

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

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

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

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

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

func NewPoolUnifRnd() *PoolUnifRnd

func (*PoolUnifRnd) Connect

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

func (*PoolUnifRnd) ConnectPoolsRnd

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

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

func (ur *PoolUnifRnd) Name() string

type Rect

type Rect struct {
	Size       evec.Vec2i `desc:"size of rectangle in sending layer that each receiving unit receives from"`
	Start      evec.Vec2i `` /* 135-byte string literal not displayed */
	Scale      mat32.Vec2 `` /* 139-byte string literal not displayed */
	AutoScale  bool       `` /* 147-byte string literal not displayed */
	RoundScale bool       `` /* 197-byte string literal not displayed */
	Wrap       bool       `desc:"if true, connectivity wraps around all edges if it would otherwise go off the edge -- if false, then edges are clipped"`
	SelfCon    bool       `desc:"if true, and connecting layer to itself (self projection), then make a self-connection from unit to itself"`
	RecvStart  evec.Vec2i `desc:"starting position in receiving layer -- if > 0 then units below this starting 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

func NewRect() *Rect

func (*Rect) Connect

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

func (*Rect) Defaults

func (cr *Rect) Defaults()

func (*Rect) Name

func (cr *Rect) Name() string

type SigmoidTopo

type SigmoidTopo struct {
	On      bool    `desc:"use gaussian topographic weights / scaling values"`
	Gain    float32 `` /* 193-byte string literal not displayed */
	CtrMove float32 `` /* 251-byte string literal not displayed */
}

SigmoidTopo has parameters for Gaussian topographic weights or scaling factors

func (*SigmoidTopo) Defaults

func (gt *SigmoidTopo) Defaults()

type UnifRnd

type UnifRnd struct {
	PCon    float32 `min:"0" max:"1" desc:"probability of connection (0-1)"`
	RndSeed int64   `view:"-" desc:"the current random seed"`
	SelfCon bool    `desc:"if true, and connecting layer to itself (self projection), then make a self-connection from unit to itself"`
	Recip   bool    `` /* 192-byte string literal not displayed */
}

UnifRnd implements uniform random pattern of connectivity between two layers uses a permuted (shuffled) list for without-replacement randomness and maintains its own local random seed for fully replicable results (if seed is not set when run, then random number generator is used to create seed) should reset seed after calling to resume sequence appropriately

func NewUnifRnd

func NewUnifRnd() *UnifRnd

func (*UnifRnd) Connect

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

func (*UnifRnd) ConnectFull

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

func (*UnifRnd) ConnectRecip

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

ConnectRecip does reciprocal connectvity

func (*UnifRnd) Name

func (ur *UnifRnd) Name() string

Jump to

Keyboard shortcuts

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