Skip to main content
Deno 2 is finally here 🎉️
Learn more


Netsaur


netsaur stars netsaur releases netsaur License


neural network deno module using neo

Maintainers

Usage

import { NeuralNetwork } from "https://deno.land/x/netsaur/mod.ts";

const net = await new NeuralNetwork({
  hidden: [
    { size: 2, activation: "sigmoid" },
  ],
  cost: "crossentropy",
  output: { size: 1, activation: "sigmoid" },
  input: {
    type: "f32",
  },
}).setupBackend(false);

net.train(
  [
    { inputs: [0, 0], outputs: [0] },
    { inputs: [1, 0], outputs: [1] },
    { inputs: [0, 1], outputs: [1] },
    { inputs: [1, 1], outputs: [0] },
  ],
  1000,
  1,
  0.1,
);

console.log(net.predict(new Float32Array([0, 0])));
console.log(net.predict(new Float32Array([1, 0])));
console.log(net.predict(new Float32Array([0, 1])));
console.log(net.predict(new Float32Array([1, 1])));