-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathComputeAMWritable.java
44 lines (37 loc) · 1.19 KB
/
ComputeAMWritable.java
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
// Associative memory to provide medium term memory.
// Reads input address from one gathered source and scatters the result.
// Reads input from another source as an address and stores to the writable area.
package s6regen;
public final class ComputeAMWritable extends Compute {
private final AM memory;
private final int location;
public ComputeAMWritable(Reservoir r, int density, int writableLocation) {
super(r);
memory = new AM(r.computeSize, density);
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();
}
}