Upload folder using huggingface_hub
Browse files- me.js +22 -9
- me.py +4 -2
- noe-model.F32.gguf +0 -0
- noe-model.dodl +0 -0
- noe-pixel-model.F32.gguf +0 -0
- noe-pixel-model.dodl +0 -0
me.js
CHANGED
|
@@ -6,6 +6,7 @@ const motionPreference = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
| 6 |
const pixelSize = 5;
|
| 7 |
const maxVelocity = 3;
|
| 8 |
const maxModelSize = 1024 * 1024;
|
|
|
|
| 9 |
const state = {
|
| 10 |
x: pixelSize / 2 + Math.random() * Math.max(0, window.innerWidth - pixelSize),
|
| 11 |
y: pixelSize / 2 + Math.random() * Math.max(0, window.innerHeight - pixelSize),
|
|
@@ -60,9 +61,10 @@ async function loadPixelModel() {
|
|
| 60 |
inputSize !== 8 ||
|
| 61 |
!Number.isSafeInteger(hiddenSize) ||
|
| 62 |
hiddenSize < 1 ||
|
|
|
|
| 63 |
outputSize !== 2
|
| 64 |
) {
|
| 65 |
-
throw new Error("Expected a
|
| 66 |
}
|
| 67 |
const lengths = [inputSize * hiddenSize, hiddenSize, hiddenSize * outputSize, outputSize];
|
| 68 |
if (networkSize !== lengths.reduce((total, length) => total + length * 4, 0)) {
|
|
@@ -75,12 +77,22 @@ async function loadPixelModel() {
|
|
| 75 |
offset += length * 4;
|
| 76 |
return values;
|
| 77 |
});
|
| 78 |
-
return {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
}
|
| 80 |
|
| 81 |
function runPixelModel(model, inputs) {
|
| 82 |
-
const hidden =
|
| 83 |
-
const outputs =
|
| 84 |
for (let hiddenIndex = 0; hiddenIndex < model.hiddenSize; hiddenIndex++) {
|
| 85 |
let total = model.bias1[hiddenIndex];
|
| 86 |
const start = hiddenIndex * model.inputSize;
|
|
@@ -101,15 +113,16 @@ function runPixelModel(model, inputs) {
|
|
| 101 |
}
|
| 102 |
|
| 103 |
function createModelInputs() {
|
| 104 |
-
const
|
|
|
|
| 105 |
const hasPointer = state.mouseX >= 0 && state.mouseY >= 0;
|
| 106 |
return [
|
| 107 |
-
state.x /
|
| 108 |
-
state.y /
|
| 109 |
state.velocityX / maxVelocity,
|
| 110 |
state.velocityY / maxVelocity,
|
| 111 |
-
hasPointer ? (state.mouseX - state.x) /
|
| 112 |
-
hasPointer ? (state.mouseY - state.y) /
|
| 113 |
hasPointer ? 1 : 0,
|
| 114 |
state.excitementLevel,
|
| 115 |
];
|
|
|
|
| 6 |
const pixelSize = 5;
|
| 7 |
const maxVelocity = 3;
|
| 8 |
const maxModelSize = 1024 * 1024;
|
| 9 |
+
const maxPixelHiddenSize = 128;
|
| 10 |
const state = {
|
| 11 |
x: pixelSize / 2 + Math.random() * Math.max(0, window.innerWidth - pixelSize),
|
| 12 |
y: pixelSize / 2 + Math.random() * Math.max(0, window.innerHeight - pixelSize),
|
|
|
|
| 61 |
inputSize !== 8 ||
|
| 62 |
!Number.isSafeInteger(hiddenSize) ||
|
| 63 |
hiddenSize < 1 ||
|
| 64 |
+
hiddenSize > maxPixelHiddenSize ||
|
| 65 |
outputSize !== 2
|
| 66 |
) {
|
| 67 |
+
throw new Error("Expected a pixel model with 8 inputs, 2 outputs, and at most 128 hidden units.");
|
| 68 |
}
|
| 69 |
const lengths = [inputSize * hiddenSize, hiddenSize, hiddenSize * outputSize, outputSize];
|
| 70 |
if (networkSize !== lengths.reduce((total, length) => total + length * 4, 0)) {
|
|
|
|
| 77 |
offset += length * 4;
|
| 78 |
return values;
|
| 79 |
});
|
| 80 |
+
return {
|
| 81 |
+
inputSize,
|
| 82 |
+
hiddenSize,
|
| 83 |
+
outputSize,
|
| 84 |
+
weights1: arrays[0],
|
| 85 |
+
bias1: arrays[1],
|
| 86 |
+
weights2: arrays[2],
|
| 87 |
+
bias2: arrays[3],
|
| 88 |
+
hiddenScratch: new Float32Array(hiddenSize),
|
| 89 |
+
outputScratch: new Float32Array(outputSize),
|
| 90 |
+
};
|
| 91 |
}
|
| 92 |
|
| 93 |
function runPixelModel(model, inputs) {
|
| 94 |
+
const hidden = model.hiddenScratch;
|
| 95 |
+
const outputs = model.outputScratch;
|
| 96 |
for (let hiddenIndex = 0; hiddenIndex < model.hiddenSize; hiddenIndex++) {
|
| 97 |
let total = model.bias1[hiddenIndex];
|
| 98 |
const start = hiddenIndex * model.inputSize;
|
|
|
|
| 113 |
}
|
| 114 |
|
| 115 |
function createModelInputs() {
|
| 116 |
+
const width = Math.max(1, window.innerWidth);
|
| 117 |
+
const height = Math.max(1, window.innerHeight);
|
| 118 |
const hasPointer = state.mouseX >= 0 && state.mouseY >= 0;
|
| 119 |
return [
|
| 120 |
+
state.x / width,
|
| 121 |
+
state.y / height,
|
| 122 |
state.velocityX / maxVelocity,
|
| 123 |
state.velocityY / maxVelocity,
|
| 124 |
+
hasPointer ? (state.mouseX - state.x) / width : 0,
|
| 125 |
+
hasPointer ? ((state.mouseY - state.y) / height) * 0.7 : 0,
|
| 126 |
hasPointer ? 1 : 0,
|
| 127 |
state.excitementLevel,
|
| 128 |
];
|
me.py
CHANGED
|
@@ -369,8 +369,10 @@ class MemoryStore:
|
|
| 369 |
|
| 370 |
def limit(self):
|
| 371 |
while len(self.items) > CONFIG["MEMORY_LIMIT"]:
|
| 372 |
-
|
| 373 |
-
|
|
|
|
|
|
|
| 374 |
|
| 375 |
def get_recent(self, count=10):
|
| 376 |
return self.items[-count:]
|
|
|
|
| 369 |
|
| 370 |
def limit(self):
|
| 371 |
while len(self.items) > CONFIG["MEMORY_LIMIT"]:
|
| 372 |
+
least_important = min(
|
| 373 |
+
range(len(self.items)), key=lambda index: self.items[index]["importance"]
|
| 374 |
+
)
|
| 375 |
+
self.items.pop(least_important)
|
| 376 |
|
| 377 |
def get_recent(self, count=10):
|
| 378 |
return self.items[-count:]
|
noe-model.F32.gguf
CHANGED
|
Binary files a/noe-model.F32.gguf and b/noe-model.F32.gguf differ
|
|
|
noe-model.dodl
CHANGED
|
Binary files a/noe-model.dodl and b/noe-model.dodl differ
|
|
|
noe-pixel-model.F32.gguf
CHANGED
|
Binary files a/noe-pixel-model.F32.gguf and b/noe-pixel-model.F32.gguf differ
|
|
|
noe-pixel-model.dodl
CHANGED
|
Binary files a/noe-pixel-model.dodl and b/noe-pixel-model.dodl differ
|
|
|