Skip to main content
Home

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
100%
Published
a year ago (1.2.6)

deno-neurons

Pure-deno implementation of neural network.

Example

Neural network to recognize a circular wave.

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

// Generate training inputs and outputs
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))]);
}

// Define neural network
const network = new Network(2).dense(8).lrelu.dense(6).lrelu.dense(1).tanh;

// Perform training of neural network
const train = new Train(network, inputs, outputs);
train.epsilon = 0.01;
train.callback = (iteration: number, loss: number[]) =>
  console.log(`Iteration: ${iteration}, Loss: ${loss[loss.length - 1]}`);
const max_iteration = 20000;
const learning_rate = 0.2;
train.run(max_iteration, learning_rate);

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

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@sauber/neurons

Import symbol

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

Import directly with a jsr specifier

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

Add Package

pnpm i jsr:@sauber/neurons
or (using pnpm 10.8 or older)
pnpm dlx jsr add @sauber/neurons

Import symbol

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

Add Package

yarn add jsr:@sauber/neurons
or (using Yarn 4.8 or older)
yarn dlx jsr add @sauber/neurons

Import symbol

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

Add Package

vlt install jsr:@sauber/neurons

Import symbol

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

Add Package

npx jsr add @sauber/neurons

Import symbol

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

Add Package

bunx jsr add @sauber/neurons

Import symbol

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