Deep Learning with deeplearnjs

deeplearnjs is a hardware-accelerated deep learning library for the web.
deeplearnjs is pretty awesome because we can use GPU via WebGL.

Using deeplearnjs

$ git clone
$ cd deeplearnjs
$ npm run prep
$ ./scripts/build-standalone.shls
$ cd demo
$ mkdir mydemo

Then create two files. One is index.html and the other is test.ts.

index.html<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<h1>deeplearn test</h1>
<div id="output"></div>
<script src="bundle.js"></script>

import {Array1D, NDArrayMathGPU, Scalar} from ‘../deeplearnjs’;
const math = new NDArrayMathGPU();
const a =[1, 2, 3]);
const b =;
math.scope(() => {
const result = math.add(a, b);
console.log(result.getValues()); // Float32Array([3, 4, 5])
$ ./scripts/watch-demo demos/mydemo/test.ts
Image for post
Image for post

Written by

#CreativeCoding #Art #PhysicalComputing #IoT #MachineLearning #python #creativetech

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store