Skip to main content

Built and signed on GitHub Actions

Pure-deno implementation of neural network inspired by Micrograd.

This package works with DenoIt is unknown whether this package works with Cloudflare Workers, Node.js, Bun, Browsers
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Node.js
This package works with Deno
It is unknown whether this package works with Bun
It is unknown whether this package works with Browsers
JSR Score
88%
Published
6 days ago (1.1.3)

deno-neurons

Pure-deno implementation of neural network.

Example

Neural network to recognize a circular wave.

import { Network, Train, Dashboard } from "jsr:@sauber/neurons";

const network = new Network(2).dense(8).lrelu.dense(6).lrelu.dense(1).tanh;
const inputs: number[][] = [];
const outputs: number[][] = [];
for (let i = 0; i < 100; ++i) {
  const [x, y] = [Math.random() * 14 - 7, Math.random() * 14 - 7];
  inputs.push([x, y]);
  outputs.push([-Math.sin(Math.sqrt(x * x + y * y))]);
}

const train = new Train(network, inputs, outputs);
train.epsilon = 0.01;
const dashboard = new Dashboard(train, 78, 16);
const max_iteration = 20000;
const learning_rate = 0.2;
const count = train.run(max_iteration, learning_rate);
console.log("Network trained in", count, "iterations.");

See Also

Use ML-CLI-Dashboard for ascii dashboard visualization during training.

Credits

Based on MicrogradTS

License

See LICENSE.

Built and signed on
GitHub Actions
View transparency log

Add Package

deno add jsr:@sauber/neurons

Import symbol

import * as mod from "@sauber/neurons";

---- OR ----

Import directly with a jsr specifier

import * as mod from "jsr:@sauber/neurons";

Add Package

npx jsr add @sauber/neurons

Import symbol

import * as mod from "@sauber/neurons";

Add Package

yarn dlx jsr add @sauber/neurons

Import symbol

import * as mod from "@sauber/neurons";

Add Package

pnpm dlx jsr add @sauber/neurons

Import symbol

import * as mod from "@sauber/neurons";

Add Package

bunx jsr add @sauber/neurons

Import symbol

import * as mod from "@sauber/neurons";