Machine Learning

for Chroma Fieldguide

Machine Learning

for Fieldguide


How to classify a moth without knowing anything about moths

A conversation between Man & Machine

Ok sure, teach me how to do it, in simple terms!

Let's learn to classify Moths!

Ok, but I can't generalise from raw images!

Ok, here is 10,000 photos of moths & their categories

What do you want then?

I need features. I work with numbers!

Ok, use 

How to classify a Moth photo:

  1. Identify the pose

  2. Identify the main colour

  3. Look for one of these distinctive patterns..

  4. ....
Oh man, this is hard. I've got to do mollusks and fish and beer bottles too..
Isn't there an easier way?

How to classify a Moth photo:

  1. Convert the image into a set of numbers

  2. Find other images in the database with the most similar numbers to your search image

  3. Pick the category of the closest image

Sounds easy!
But.. how do I convert an image to a set of numbers?

Feed the image through a pretrained neural network classifier and extract the values of one of the inner layers.

But.. how do I convert an image to a set of numbers?

Just use ImageNet.. It is a neural network that has learned all about vision and the features that make up images. Its inner layers are general image descriptors..


Think of it as a black box translator from pixels to semantics.

ok.. so what is the output?

A list of 4096 numbers!

And what do they mean?

Nobody knows! Nothing individually, but together they describe higher level features of images.

oh yeah... of course...

Well its just a point in a 4096 dimensional space.. so you just calculate the distance between them?

So how do I compare these numbers?

Doesn't matter, you don't need to visualise it.. just calculate the distance in the same way as 2d space.. square root of the sum of the squared differences, remember?

4096 dimensional..wat!
oh of those greek dudes said that yeah?
Dude I don't even get 3D!
Ok, so my database has 100k images and their 4096 dim numbers.. How do I know which ones to compare against?

You don't! You need to calculate the distance to all of them.

But.. 100k.. and counting!

You better do it quick so! Just use Postgres, all will be fine :) Oh and you can do a rough search first across binarized codes using Hamming distance.. it's super fast.

Ok, awesome, it works, it is fast! 
But am I  really learning?

I feel like this isn't real machine learning? We are still using someone else's neural net..

Of course you are. As we add more data the results get better.  The neural net is just a generic vision translator.

But I don't think I know what a moth is!

Of course you don't!  But you don't need to. You need to classify moths, not describe them.

Fair enough, but that doesn't sound very intelligent

You're not. You are just doing statistics & math. Nothing special.

Aww.. that hurts :(
But no one else needs to know that.. I can pretend I am an all powerful AI, even smarter than Siri.. 

just with a Moth obsession..

It's a job! Just don't tell anyone else how I do it ok.. 

What do we mean by "Learning"?

Machine Learning

  • AI

  • Pattern Recognition

  • Statistics

  • The output is not solely determined by code

  • Its accuracy at a task can be improved with training

A system is learning if:

  • Providing samples of inputs and expected outputs

  • Providing positive/negative feedback


How does it learn?

A machine learning system includes a model of its domain. Usually statistics about data.

When it learns it updates this model.

When it makes a prediction it consults the model.


Height - Weight - Gender Classifier

But what about images?

Convert images into numbers so we can measure their similarity. 

Sounds easy!


  • A colour histogram

  • Detect and count features/shapes

  • => Create a feature vector (list of numbers)


Classifying images with

Neural Networks

How to train your Neural Network

1. Set the top input layer to raw pixel values.

2. Calculate the values of the next layer from the previous layer and the 

3. Repeat 2 until final layer.

4. Calculate the difference between the outputs and the expected output 



What does Deep refer to?

Deep Learning

By Fergal Walsh

Deep Learning

  • 354
Loading comments...

More from Fergal Walsh