-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathfull.go
46 lines (39 loc) · 1.04 KB
/
full.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright (c) 2019, The Emergent Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package paths
import "cogentcore.org/lab/tensor"
// Full implements full all-to-all pattern of connectivity between two layers
type Full struct {
// if true, and connecting layer to itself (self pathway), then make a self-connection from unit to itself
SelfCon bool
}
func NewFull() *Full {
return &Full{}
}
func (fp *Full) Name() string {
return "Full"
}
func (fp *Full) Connect(send, recv *tensor.Shape, same bool) (sendn, recvn *tensor.Int32, cons *tensor.Bool) {
sendn, recvn, cons = NewTensors(send, recv)
cons.Values.SetAll(true)
nsend := send.Len()
nrecv := recv.Len()
if same && !fp.SelfCon {
for i := 0; i < nsend; i++ { // nsend = nrecv
off := i*nsend + i
cons.Values.Set(false, off)
}
nsend--
nrecv--
}
rnv := recvn.Values
for i := range rnv {
rnv[i] = int32(nsend)
}
snv := sendn.Values
for i := range snv {
snv[i] = int32(nrecv)
}
return
}