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 ¶
- func ConsStringFull(send, recv *etensor.Shape, cons *etensor.Bits) []byte
- func ConsStringPerRecv(send, recv *etensor.Shape, cons *etensor.Bits) []byte
- func NewTensors(send, recv *etensor.Shape) (sendn, recvn *etensor.Int32, cons *etensor.Bits)
- type Circle
- type Full
- type GaussTopo
- type OneToOne
- type Pattern
- type PoolOneToOne
- func (ot *PoolOneToOne) Connect(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)
- func (ot *PoolOneToOne) ConnectOneToOne(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)
- func (ot *PoolOneToOne) ConnectPools(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)
- func (ot *PoolOneToOne) ConnectRecvPool(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)
- func (ot *PoolOneToOne) ConnectSendPool(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)
- func (ot *PoolOneToOne) Name() string
- type PoolRect
- type PoolSameUnit
- func (ot *PoolSameUnit) Connect(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)
- func (ot *PoolSameUnit) ConnectOneToOne(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)
- func (ot *PoolSameUnit) ConnectPools(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)
- func (ot *PoolSameUnit) ConnectRecvPool(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)
- func (ot *PoolSameUnit) ConnectSendPool(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)
- func (ot *PoolSameUnit) Name() string
- type PoolTile
- func (pt *PoolTile) Connect(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)
- func (pt *PoolTile) ConnectRecip(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)
- func (pt *PoolTile) Defaults()
- func (pt *PoolTile) GaussOff()
- func (pt *PoolTile) HasTopoWts() bool
- func (pt *PoolTile) Name() string
- func (pt *PoolTile) TopoWts(send, recv *etensor.Shape, wts *etensor.Float32) error
- func (pt *PoolTile) TopoWtsGauss2D(send, recv *etensor.Shape, wts *etensor.Float32) error
- func (pt *PoolTile) TopoWtsGauss4D(send, recv *etensor.Shape, wts *etensor.Float32) error
- func (pt *PoolTile) TopoWtsSigmoid2D(send, recv *etensor.Shape, wts *etensor.Float32) error
- func (pt *PoolTile) TopoWtsSigmoid4D(send, recv *etensor.Shape, wts *etensor.Float32) error
- type PoolTileSub
- func (pt *PoolTileSub) Connect(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)
- func (pt *PoolTileSub) ConnectRecip(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)
- func (pt *PoolTileSub) Defaults()
- func (pt *PoolTileSub) GaussOff()
- func (pt *PoolTileSub) HasTopoWts() bool
- func (pt *PoolTileSub) Name() string
- func (pt *PoolTileSub) TopoWts(send, recv *etensor.Shape, wts *etensor.Float32) error
- func (pt *PoolTileSub) TopoWtsGauss2D(send, recv *etensor.Shape, wts *etensor.Float32) error
- func (pt *PoolTileSub) TopoWtsGauss4D(send, recv *etensor.Shape, wts *etensor.Float32) error
- func (pt *PoolTileSub) TopoWtsSigmoid2D(send, recv *etensor.Shape, wts *etensor.Float32) error
- func (pt *PoolTileSub) TopoWtsSigmoid4D(send, recv *etensor.Shape, wts *etensor.Float32) error
- type PoolUnifRnd
- func (ur *PoolUnifRnd) Connect(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)
- func (ur *PoolUnifRnd) ConnectPoolsRnd(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)
- func (ur *PoolUnifRnd) ConnectRnd(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)
- func (ur *PoolUnifRnd) Name() string
- type Rect
- type SigmoidTopo
- type UnifRnd
- func (ur *UnifRnd) Connect(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)
- func (ur *UnifRnd) ConnectFull(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)
- func (ur *UnifRnd) ConnectRecip(send, recv *etensor.Shape, same bool) (sendn, recvn *etensor.Int32, cons *etensor.Bits)
- func (ur *UnifRnd) InitRand()
- func (ur *UnifRnd) Name() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConsStringFull ¶
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 ¶
ConsStringPerRecv returns a []byte string showing the pattern of connectivity organized by receiving unit, showing the sending connections per each
Types ¶
type Circle ¶
type Circle struct { // radius of the circle, in units from center in sending layer Radius int // starting offset in sending layer, for computing the corresponding sending center relative to given recv unit position Start evec.Vec2i // scaling to apply to receiving unit position to compute sending center as function of recv unit position Scale mat32.Vec2 // 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 // if true, connectivity wraps around edges Wrap bool // if true, this prjn should set gaussian topographic weights, according to following parameters TopoWts bool // gaussian sigma (width) as a proportion of the radius of the circle Sigma float32 // maximum weight value for GaussWts function -- multiplies values MaxWt float32 // if true, and connecting layer to itself (self projection), then make a self-connection from unit to itself SelfCon bool }
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.
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 }
Full implements full all-to-all pattern of connectivity between two layers
type GaussTopo ¶
type GaussTopo struct { // use gaussian topographic weights / scaling values On bool // 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 `viewif:"On" default:"0.6"` // 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 `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 `viewif:"On" default:"0.8,1"` }
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)
type OneToOne ¶
type OneToOne struct { // number of recv connections to make (0 for entire size of recv layer) NCons int // starting unit index for sending connections SendStart int // starting unit index for recv connections RecvStart int }
OneToOne implements point-to-point one-to-one pattern of connectivity between two layers
func NewOneToOne ¶
func NewOneToOne() *OneToOne
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 // starting pool index for sending connections SendStart int // starting pool index for recv connections RecvStart int }
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) 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 of rectangle (of pools) in sending layer that each receiving unit receives from Size evec.Vec2i // starting pool offset in sending layer, for computing the corresponding sending lower-left corner relative to given recv pool position Start evec.Vec2i // scaling to apply to receiving pool osition to compute corresponding position in sending layer of the lower-left corner of rectangle Scale mat32.Vec2 // 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 // 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 // if true, connectivity wraps around all edges if it would otherwise go off the edge -- if false, then edges are clipped Wrap bool // if true, and connecting layer to itself (self projection), then make a self-connection from unit to itself SelfCon bool // starting pool position in receiving layer -- if > 0 then pools below this starting point remain unconnected RecvStart evec.Vec2i // 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 }
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
type PoolSameUnit ¶
type PoolSameUnit struct { // if true, and connecting layer to itself (self projection), then make a self-connection from unit to itself SelfCon bool }
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) 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 { // reciprocal topographic connectivity -- logic runs with recv <-> send -- produces symmetric back-projection or topo prjn when sending layer is larger than recv Recip bool // size of receptive field tile, in terms of pools on the sending layer Size evec.Vec2i // how many pools to skip in tiling over sending layer -- typically 1/2 of Size Skip evec.Vec2i // starting pool offset for lower-left corner of first receptive field in sending layer Start evec.Vec2i // if true, pool coordinates wrap around sending shape -- otherwise truncated at edges, which can lead to assymmetries in connectivity etc Wrap bool // gaussian topographic weights / scaling parameters for full receptive field width. multiplies any other factors present GaussFull GaussTopo // 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 // 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 // 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 // min..max range of topographic weight values to generate TopoRange minmax.F32 }
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 ¶
NewPoolTileRecip creates a new PoolTile that is a recip version of given ff feedforward one
func (*PoolTile) ConnectRecip ¶
func (*PoolTile) HasTopoWts ¶
HasTopoWts returns true if some form of topographic weight patterns are set
func (*PoolTile) TopoWts ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 { // reciprocal topographic connectivity -- logic runs with recv <-> send -- produces symmetric back-projection or topo prjn when sending layer is larger than recv Recip bool // size of receptive field tile, in terms of pools on the sending layer Size evec.Vec2i // how many pools to skip in tiling over sending layer -- typically 1/2 of Size Skip evec.Vec2i // starting pool offset for lower-left corner of first receptive field in sending layer Start evec.Vec2i // number of sub-pools within each pool Subs evec.Vec2i // sending layer has sub-pools SendSubs bool // if true, pool coordinates wrap around sending shape -- otherwise truncated at edges, which can lead to assymmetries in connectivity etc Wrap bool // gaussian topographic weights / scaling parameters for full receptive field width. multiplies any other factors present GaussFull GaussTopo // 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 // 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 // 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 // min..max range of topographic weight values to generate TopoRange minmax.F32 }
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) ConnectRecip ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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) 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 of rectangle in sending layer that each receiving unit receives from Size evec.Vec2i // starting offset in sending layer, for computing the corresponding sending lower-left corner relative to given recv unit position Start evec.Vec2i // scaling to apply to receiving unit position to compute corresponding position in sending layer of the lower-left corner of rectangle Scale mat32.Vec2 // 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 // 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 // if true, connectivity wraps around all edges if it would otherwise go off the edge -- if false, then edges are clipped Wrap bool // if true, and connecting layer to itself (self projection), then make a self-connection from unit to itself SelfCon bool // make the reciprocal of the specified connections -- i.e., symmetric for swapping recv and send Recip bool // starting position in receiving layer -- if > 0 then units below this starting point remain unconnected RecvStart evec.Vec2i // 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 }
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 NewRectRecip ¶
NewRectRecip creates a new Rect that is a Recip version of given ff one
func (*Rect) ConnectRecip ¶
type SigmoidTopo ¶
type SigmoidTopo struct { // use gaussian topographic weights / scaling values On bool // 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 `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 `viewif:"On" default:"0.5,1"` }
SigmoidTopo has parameters for Gaussian topographic weights or scaling factors
func (*SigmoidTopo) Defaults ¶
func (gt *SigmoidTopo) Defaults()
type UnifRnd ¶
type UnifRnd struct { // probability of connection (0-1) PCon float32 `min:"0" max:"1"` // if true, and connecting layer to itself (self projection), then make a self-connection from unit to itself SelfCon bool // 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 // random number source -- is created with its own separate source if nil Rand erand.Rand `view:"-"` // the current random seed -- will be initialized to a new random number from the global random stream when Rand is created. RndSeed int64 `view:"-"` }
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 ¶
func NewUnifRnd() *UnifRnd