@buley/neural 2.0.2 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/engine/gpu.ts +4 -4
- package/src/index.ts +6 -3
- package/src/types.ts +1 -1
package/package.json
CHANGED
package/src/engine/gpu.ts
CHANGED
|
@@ -112,7 +112,7 @@ export class GPUEngine {
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
// Upload Input
|
|
115
|
-
this.device.queue.writeBuffer(this.inputBuffer, 0, inputs as
|
|
115
|
+
this.device.queue.writeBuffer(this.inputBuffer, 0, inputs as BufferSource);
|
|
116
116
|
|
|
117
117
|
// Encode Command
|
|
118
118
|
const commandEncoder = this.device.createCommandEncoder();
|
|
@@ -213,7 +213,7 @@ export class GPUEngine {
|
|
|
213
213
|
// Let's assume prepareTrainingBuffers was called ONCE before loop.
|
|
214
214
|
// We just need to update TARGETS buffer!
|
|
215
215
|
if (this.targetBuffer) {
|
|
216
|
-
this.device?.queue.writeBuffer(this.targetBuffer, 0, targets as
|
|
216
|
+
this.device?.queue.writeBuffer(this.targetBuffer, 0, targets as BufferSource);
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
// Run Training Shaders
|
|
@@ -229,7 +229,7 @@ export class GPUEngine {
|
|
|
229
229
|
}
|
|
230
230
|
|
|
231
231
|
if (deltas && deltas.length > 0) {
|
|
232
|
-
this.device.queue.writeBuffer(this.deltaBuffer, 0, deltas as
|
|
232
|
+
this.device.queue.writeBuffer(this.deltaBuffer, 0, deltas as BufferSource);
|
|
233
233
|
}
|
|
234
234
|
|
|
235
235
|
const commandEncoder = this.device.createCommandEncoder();
|
|
@@ -258,7 +258,7 @@ export class GPUEngine {
|
|
|
258
258
|
|
|
259
259
|
// We only write what we are given, usually just the first N inputs (Microphone bins)
|
|
260
260
|
// If data is smaller than buffer, we use queue.writeBuffer which handles partial writes
|
|
261
|
-
this.device.queue.writeBuffer(this.inputBuffer, 0, data as
|
|
261
|
+
this.device.queue.writeBuffer(this.inputBuffer, 0, data as BufferSource);
|
|
262
262
|
|
|
263
263
|
// Trigger a tick? Or let the outer loop do it?
|
|
264
264
|
// Let's just update the buffer. The UI loop calls runTick() or similar.
|
package/src/index.ts
CHANGED
|
@@ -3,6 +3,9 @@ import { initializeSchema } from "./db/schema";
|
|
|
3
3
|
import { NeuronRepository, SynapseRepository } from "./db/repository";
|
|
4
4
|
import { GPUEngine } from "./engine/gpu";
|
|
5
5
|
import { Translator } from "./engine/translator";
|
|
6
|
+
import { Neuron, Synapse } from "./types";
|
|
7
|
+
|
|
8
|
+
export type { Neuron, Synapse } from "./types";
|
|
6
9
|
|
|
7
10
|
export class NeuralEngine {
|
|
8
11
|
gpu: GPUEngine;
|
|
@@ -18,8 +21,8 @@ export class NeuralEngine {
|
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
// Cache
|
|
21
|
-
private neurons:
|
|
22
|
-
private synapses:
|
|
24
|
+
private neurons: Neuron[] = [];
|
|
25
|
+
private synapses: Synapse[] = [];
|
|
23
26
|
|
|
24
27
|
async init() {
|
|
25
28
|
console.log("Neural 2.0 Engine Initializing...");
|
|
@@ -146,7 +149,7 @@ export class NeuralEngine {
|
|
|
146
149
|
};
|
|
147
150
|
}
|
|
148
151
|
|
|
149
|
-
async importGraph(data:
|
|
152
|
+
async importGraph(data: { neurons: Neuron[], synapses: Synapse[] }) {
|
|
150
153
|
if (!data.neurons || !data.synapses) throw new Error("Invalid graph data");
|
|
151
154
|
|
|
152
155
|
console.log("Importing graph...");
|