Rubyconf Neural Networks

38
Driven Neural Networks Matthew Kirk - Modulus 7

description

Neural networks are an excellent way of mapping past observations to a functional model. Many researchers have been able to build tools to recognize handwriting, or even jaundice detection. While Neural Networks are powerful they still are somewhat of a mystery to many. This talk aims to explain neural networks in a test driven way. We'll write tests first and go through how to build a neural network to determine what language a sentence is. By the end of this talk you'll know how to build neural networks with tests!

Transcript of Rubyconf Neural Networks

Page 1: Rubyconf Neural Networks

Test Driven Neural

Networks

Matthew Kirk - Modulus 7

Page 2: Rubyconf Neural Networks
Page 3: Rubyconf Neural Networks

automatic playlists

Page 4: Rubyconf Neural Networks

The Challenge

Page 5: Rubyconf Neural Networks

“Big Data” Language

sJavaPythonRJuliaClojure

Page 6: Rubyconf Neural Networks

Ruby has tools too

Page 7: Rubyconf Neural Networks
Page 8: Rubyconf Neural Networks

Ruby is not Complex Math

Page 9: Rubyconf Neural Networks

Today we’ll cover

• What feed forward neural networks are

• How to classify strings to languages using Neural Nets

• How to do it in a TDD fashion

• Demonstration

Page 10: Rubyconf Neural Networks

Neural Networks!

aka the sledge hammer of functional relationships

Page 11: Rubyconf Neural Networks

Neural Networks

Page 12: Rubyconf Neural Networks

Input layer

Page 13: Rubyconf Neural Networks

Hidden layer

Page 14: Rubyconf Neural Networks

How many Neurons?

•2/3 * Input layer count + output count is a good start

•Aggregation over expansion so less neurons in the hidden layer than on the input layer.

Page 15: Rubyconf Neural Networks

Output layer

Page 16: Rubyconf Neural Networks

Neurons

Page 17: Rubyconf Neural Networks

Digital Logic

Page 18: Rubyconf Neural Networks

Fuzzy Logic

Page 19: Rubyconf Neural Networks

Activation Functions

•Sigmoid

•Elliott

•Gaussian

•Linear

•Threshold

•Cosine and Sine

Page 20: Rubyconf Neural Networks

Activation Functions

•Sigmoid => Learning Curve

•Elliott => Learning Curve

•Gaussian => Bell curve

•Linear => Line

•Threshold => Yes or No

•Cosine and Sine => Periodic

Page 21: Rubyconf Neural Networks
Page 22: Rubyconf Neural Networks

Training Algorithms

•Quickprop

•RProp => Use this

•Back propagation

Page 23: Rubyconf Neural Networks

Visually What they do

Page 24: Rubyconf Neural Networks

Neural NetsJust the tip of the iceberg

Page 25: Rubyconf Neural Networks
Page 26: Rubyconf Neural Networks

Specifically

•English

•German

•Polish

•Swedish

•Finnish

•Norwegian

Page 27: Rubyconf Neural Networks

Data Collection

•Using the most translated book in the world “The Bible” to collect sentences used in each of these languages.

Page 28: Rubyconf Neural Networks

Now What?

Page 29: Rubyconf Neural Networks
Page 30: Rubyconf Neural Networks

Character Distribution

Page 31: Rubyconf Neural Networks

TDD Neural Nets

Page 32: Rubyconf Neural Networks

Test the Seams

describe Language do it 'has the proper keys for each vector'

it 'sums to 1 for all vectors'

it 'returns characters that is a unique set of characters used'end

Page 33: Rubyconf Neural Networks

Cross Validation

describe Network do %w[English Finnish German Norwegian Polish Swedish].each do |lang| it "Trains and cross-validates with an error of 5% for #{lang}" endend

Page 34: Rubyconf Neural Networks

Ockham’s Razor

Page 35: Rubyconf Neural Networks

Demo

Page 36: Rubyconf Neural Networks

modulus7.com/rubyconf

@mjkirk

Page 37: Rubyconf Neural Networks

Conclusion

This is just the beginning

Go learn more become more adept at data analysis

Page 38: Rubyconf Neural Networks

http://rickmanelius.com/article/do-you-dread-emails

http://www.flickr.com/photos/irisheyes/8469160004/

http://www.flickr.com/photos/andy_bernay-roman/2206610268/

http://www.flickr.com/photos/kev_walsh/2216144544/sizes/o/in/photostream/

http://www.flickr.com/photos/clover_1/2926385130/

http://www.flickr.com/photos/andy_bernay-roman/2206610268/sizes/o/in/photostream/

http://translate.google.com

http://www.flickr.com/photos/epistemographer/68200471

http://www.allaboutcircuits.com/vol_4/chpt_3/5.html

http://www.flickr.com/photos/brunobord/3987593006/

Photo Credits