-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComputeAMThresholdGatedWritable.java
More file actions
45 lines (38 loc) · 1.32 KB
/
Copy pathComputeAMThresholdGatedWritable.java
File metadata and controls
45 lines (38 loc) · 1.32 KB
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
// Associative memory to provide long term memory.
// Reads input address from one gathered source and scatters the result to the writable section.
// Reads input from another source as an address and stores a further source after
// threshold gating.
package s6regen;
public final class ComputeAMThresholdGatedWritable extends Compute {
private final AMThresholdGated memory;
private final int location;
public ComputeAMThresholdGatedWritable(Reservoir r, int density,float threshold, int writableLocation) {
super(r);
memory = new AMThresholdGated(r.computeSize, density,threshold);
location = writableLocation;
}
@Override
public void compute() {
float[] workA = reservoir.computeBuffers[0];
float[] workB = reservoir.computeBuffers[1];
float[] workC = reservoir.computeBuffers[2];
reservoir.gather(workA);
reservoir.gather(workB);
reservoir.gather(workC);
memory.recallVec(workA, workA);
reservoir.scatterWritable(workA, location);
memory.trainVec(workC, workB);
}
@Override
public int weightSize() {
return 3 * reservoir.sizeGather();
}
@Override
public int buffersRequired() {
return 3;
}
@Override
public void resetHeldState() {
memory.reset();
}
}