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).
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 Full
- 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) HasWeights() bool
- func (ot *PoolOneToOne) Name() string
- func (ot *PoolOneToOne) Weights(sendn, recvn *etensor.Int32, cons *etensor.Bits) []float32
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 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 (*Full) HasWeights ¶
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) HasWeights ¶
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) // HasWeights returns true if this projection can provide initial synaptic weights // for connected units, via the Weights method. HasWeights() bool // Weights provides initial synaptic weights for each of the connected units. // For efficiency, the weights are provided for connected units -- i.e., only for // the cons = true bits -- values are in receiver-outer, sender-inner order. // Typically, these weights reflect an overall topographic pattern and do NOT include // random perturbations, which can be added on top. Weights(sendn, recvn *etensor.Int32, cons *etensor.Bits) []float32 }
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 { NCons 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 a one-to-one pattern of connectivity between the sub-pools of units within two layers sub-pools are present for layers with a 4D shape, as the outer-most two dimensions of that 4D 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) HasWeights ¶
func (ot *PoolOneToOne) HasWeights() bool
func (*PoolOneToOne) Name ¶
func (ot *PoolOneToOne) Name() string