Surprisingly, despite AI’s breadth of impact, the types of it being deployed are still extremely limited. Almost all of AI’s recent progress is through one type, in which some input data (A) is used to quickly generate some simple response (B)
Andrew Ng: https://hbr.org/2016/11/what-artificial-intelligence-can-and-cant-do-right-now
Built using deeplearn.js (more on that later in this talk), source code available
Full TypeScript ML library using browser GPU
https://pair-code.github.io/deeplearnjs
Includes full training mimicking TensorFlow and NumPy API https://research.googleblog.com/2017/08/harness-power-of-machine-learning-in.html
const math = new NDArrayMathGPU();
// const math = new NDArrayMathCPU();
const array = Array1D.new([1, 2, 3]);
const scalar = Scalar.new(2);
const result = math.scalarTimesArray(scalar, array);
console.log(await result.data());
// => Float32Array([2, 4, 6])
Fit a polynomial curve through some data points
y = a * x2 + b * x + c
const graph = new Graph();
const x = graph.placeholder('x', []);
const a = graph.variable('a', Scalar.new(Math.random()));
const b = graph.variable('b', Scalar.new(Math.random()));
const c = graph.variable('c', Scalar.new(Math.random()));
const order2 = graph.multiply(a, graph.square(x));
const order1 = graph.multiply(b, x);
const y = graph.add(graph.add(order2, order1), c);
wildly asynchronous, but async/await
help
const math = new NDArrayMathGPU(); // could also be CPU
const session = new Session(graph, math);
const sampleX = 4;
math.scope(async (keep, track) => {
const result =
session.eval(y, [{ tensor: x,
data: track(Scalar.new(sampleX))
}]);
console.log(await result.get())
});
GPU resource management is partially on us (keep, track
)
Long running, complex computations on GPU
const yLabel = graph.placeholder('y label', []);
const cost = graph.meanSquaredCost(y, yLabel);
const LEARNING_RATE = .01;
const optimizer = new SGDOptimizer(LEARNING_RATE);
// repeat a number of times (epochs)
session.train(
cost,
// matching x/y pairs
[{ tensor: x, data: xProvider },
{ tensor: yLabel, data: yProvider }],
optimizer, CostReduction.MEAN);
Build a neural network in your browser
Machine Learning in the Browser, hh.js 2017
Oliver Zeigermann / @DJCordhose
http://bit.ly/ml-hhjs