Jonathan Lee Martin
October 17, 2014
79

# Teach JS About Aesthetics with Machine Learning

Move over Number 5: Artificial Intelligence is a relic of 1986. It’s 2014: the era of Machine Learning + Big Data.

Machine learning helps power everything from Google Now to the lowly OS X Preview app — but you don’t have to be a Prolog or eCommerce geek to harness its power!

We’ll take a whirlwind tour through the fundamental concepts and algorithms in machine learning, then explore a frontend application: selecting the “best” photos to feature on our photo sharing site.

Don’t expect mathematically laborious derivations of SVM kernels or the infinite VC dimension of Neural Nets, but we will gain enough intuition to make informed compromises (thanks to the No Free Lunch theorem, everything is a compromise) in our pursuit of aesthetically-intelligent machines!

October 17, 2014

## Transcript

w2f2 + w3f3)
18. ### -1.5 -1 -0.5 0 0.5 1 1.5 -1.5 -1 -0.5

0.5 1 1.5 Activation f(x) = tanh(x)

37. ### var brain = require('brain'); var net = new brain.NeuralNetwork(); net.train([{input:

{ r: 0.03, g: 0.7, b: 0.5 }, output: { black: 1 }}, {input: { r: 0.16, g: 0.09, b: 0.2 }, output: { white: 1 }}, {input: { r: 0.5, g: 0.5, b: 1.0 }, output: { white: 1 }}]); var output = net.run({ r: 1, g: 0.4, b: 0 }); // => { white: 0.99, black: 0.002 }

39. ### var layers = [{ type: 'input', out_sx: 1, out_sy: 1,

out_depth: 2 }, { type: 'fc', num_neurons: 20, activation: 'relu' }, { type: 'fc', num_neurons: 40, activation: 'relu', drop_prob: 0.5 }, { type: 'softmax', num_classes: 4 }]; var convnetjs = require('convnetjs'); var net = new convnetjs.Net(); net.makeLayers(layers); var input = new convnetjs.Vol(1,1,2); // feature vector var class_probabilities = net.forward(input);