Skip to content

Commit

Permalink
Initial commit to the repository, paper included in readme.
Browse files Browse the repository at this point in the history
Authored by: @LiveBacteria (Tyler Poore)

Major functionality of the theory integration has been omitted as of this time. As such, later commits will contain the files as the theory is completed.
  • Loading branch information
LiveBacteria committed Jul 24, 2023
0 parents commit 0197b4a
Show file tree
Hide file tree
Showing 15 changed files with 5,886 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
node_modules
.vscode
vis/__pycache__
vis/neural_mesh
vis/octants
vis/adjacencyMap.json
vis/data.json
vis/test.py
vis/progress.txt
vis/visualise.py_old
trace32.exe
scratch
progress.txt
adjacencyMap.json
kdTree.js
kdtreeTest.js
nMesh.json_old
pineconeTest.js
cudaTest.js
.env
79 changes: 79 additions & 0 deletions QNN.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
class Neuron {
constructor() {
this.connections = [];
this.value = Math.random();
this.weight = Math.random();
}

connectTo(neuron) {
this.connections.push(neuron);
}
}

class Superposition {
constructor(neurons) {
this.neurons = neurons;
this.position = this.calculatePosition();
}

calculatePosition() {
let x = 0;
let y = 0;
let z = 0;

for (let neuron of this.neurons) {
x += neuron.x;
y += neuron.y;
z += neuron.z;
}

return {
x: x / this.neurons.length,
y: y / this.neurons.length,
z: z / this.neurons.length,
};
}
}

class NeuralNetwork {
constructor(size) {
this.size = size;
this.neurons = this.createNeurons();
this.superpositions = [];
}

createNeurons() {
let neurons = [];
for (let i = 0; i < this.size; i++) {
for (let j = 0; j < this.size; j++) {
for (let k = 0; k < this.size; k++) {
let neuron = new Neuron();
neuron.x = i;
neuron.y = j;
neuron.z = k;
neurons.push(neuron);
}
}
}
return neurons;
}

activateRandomNeurons(percentage) {
let numToActivate = Math.floor(this.neurons.length * percentage);
for (let i = 0; i < numToActivate; i++) {
let neuron =
this.neurons[Math.floor(Math.random() * this.neurons.length)];
neuron.value = 1;
}
}

createSuperposition() {
let activatedNe V+9urons = this.neurons.filter((neuron) => neuron.value === 1);
let superposition = new Superposition(activatedNeurons);
this.superpositions.push(superposition);
}
}

let neuralNetwork = new NeuralNetwork(20);
neuralNetwork.activateRandomNeurons(0.05);
neuralNetwork.createSuperposition();
35 changes: 35 additions & 0 deletions generateNeurons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const fs = require("fs");
const path = require("path");
const math = require("mathjs");

class Neuron {
constructor(x, y, z) {
this.x = x;
this.y = y;
this.z = z;
}
}

process.on(
"message",
({ centerX, centerY, centerZ, neuronsPerProcess, filename }) => {
// Create the directory if it doesn't exist
let dir = path.dirname(filename);
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir, { recursive: true });
}

let writeStream = fs.createWriteStream(filename, { flags: "a" });

for (let j = 0; j < neuronsPerProcess; j++) {
let x = centerX + math.random(-0.1, 0.1);
let y = centerY + math.random(-0.1, 0.1);
let z = centerZ + math.random(-0.1, 0.1);

let neuron = new Neuron(x, y, z);
writeStream.write(JSON.stringify(neuron) + ",\n");
}

writeStream.end();
}
);
Loading

0 comments on commit 0197b4a

Please sign in to comment.