Tuesday, March 24, 2015

Machine Learning - Inventing the Singularity

Machine Learning

Inventing the Singularity

Recently, the dangers of Artificial Intelligence(AI), have been raised by more than a few eminent thinkers of current times. Elon Musk even went as far as calling it inventing the Devil. Too dramatic, you might say? I have also heard from many bright minds in the middle of this Artificial Intelligence research and revolution, the people developing these machine learning technologies, people who defend the technology and dismiss the concerns being raised, claim that Elon Musk and Bill Gates don't understand the state of AI and have no idea what they are talking about.

I stand clearly and convincingly on the side that Artificial intelligence has the "potential" to be Evil, to become the devil, the singularity that consumes everything else. More powerful than the invention of the atom bomb.  I might sound like an alarmist at this point. But my conviction comes from an understanding of the nature, direction and potential of the current class of Machine Learning technology. So, let me explain.

Let me be very clear from the very beginning, I think machine learning has a huge potential to do good, be a force for good, do great things.  And we should continue to make great strides in all these areas.

But, as they say with great power comes great responsibility. It applies to machine learning. Its potential is limitless, and so are its dangers. And the dangers are even higher if we are completely oblivious to it. The following is just some insight towards, what makes it powerful, what makes it risky and unpredictable, recognizing its risks and dangers.

I have a background in artificial intelligence since my early days of engineering college, some 25 years ago. Though my day job is in all things Networking, I work for Cisco Inc, developing networking software that makes the internet do what it does, I have continued to pursue my passion for Machine Learning as a hobby throughout my adult life. So I have some insight about what I am saying below.

Very early incarnations of Artificial Intelligence were explicitly rule based, implemented in languages like PROLOG and LISP. You created rules of behavior to simulate intelligence. Then came the concept of learning these rules from raw data, hence the term Machine Learning. You would implement a generic learning algorithm that would feed on lots and lots of data and build rules from the data and then apply these rules on new and potentially unseen data. These were rigid systems that made black and white decisions.

But as we know, the real world is never truly black and white, its a million shades of grey, not just 50. Sorry. Couldn't resist that one.

Then came the statistical and probabilistic Machine Learning algorithms. People tried to develop mathematical models of the neurons in your brain and the network of neurons in your brain, also referred to as Neural Networks. These machines learned statistical and probabilistic rules and relationships from raw data and interactions with the world.

It is this new class of Learning Machines that I refer to, when I warn about the potential to be evil, the potential to be the singularity.

The current generation of these machines have become very proficient at things like recognizing speech, language, vision, etc. Self driving cars, that will be safer than humans, is already here. Its not science fiction anymore.

Ok. Machine Learning is becoming smarter by the day. And in some specific areas like vision, even smarter than humans.

But it is still a huge stretch to go from there to Evil, the Devil, the Singularity. Or is it?

Let me explain a bit more.

My conviction comes from a few key traits of this new class of machine learning algorithms.

  1. They are probabilistic decision engines.
  2. They learn their probabilistic rules from looking at large quantities of data and interacting with the real world. 
  3. Their over all decision making and interactions with the world are made from the collective decision making of millions of simple probabilistic rule nodes called neurons. 
  4. It is computationally infeasible to understand or test every potential input, interaction or decision that can be made by the collective decision making of these millions of individual probabilistic neurons.
  5. The recurrent version of these machines, are still in its infancy. These learn to make probabilistic  decisions, based not only from the current inputs, but also based on its own past probabilistic decisions and internal state. This makes these machines infinitely more complex, powerful and hard to understand what they have learnt.
  6. Larger these learning machines, larger its capacity to learn. And larger the sources of data the more they can learn from and the more complex to understand what it has learnt. 

The importance of the last 3 points above should not be under estimated and is the key to why I believe as I do.

Indulge me a for bit more. Let me elaborate on these points.

These new statistical and probabilistic machine learning algorithms don't learn explicit rules of interaction. They are NOT a collection of deterministic rules like, if this, do that. They are a huge collection of tiny probabilistic decision making neuron models that learn to make probabilistic decisions. And the intelligence of the whole machine comes from the probabilistic learning and decision making of these millions of these little nodes. 

Put it in relatively simple terms, imagine a crowd of a billion "simple", not so smart people, each voting "probabilistically", based on what they directly see or hear from the real world or from their neighbors, to collectively make every decision they make together. Ring a bell? Can you really understand the decisions they will make? Can you really know how they will decide under every condition, input or interaction? Can you really say with any certainty they the will not be evil or make catastrophic decisions. Think of every war, genocide or man made catastrophe in history before answering that question.

It is not possible to understand in real concrete terms all the rules that have been learnt by this huge collection of tiny learning machines and predict all possible outcomes that might be generated by them. Ok, its possible, but only theoretically. The computational requirement to completely understand a very large machine learning model with billions of these neurons would be exponentially higher.

This is true for the simple feed forward learning models which is the predominant machine learning technology now. Once you step into the recurrent version of these models, it becomes a dynamical system that is far more powerful and complex. They have historically been far more complex and difficult to train or understand what it has learnt. Its an area of Machine Learning that is still in its infancy, but progress is being made every year, and they are getting more powerful with time.

Their power and complexity comes from the fact that these probabilistic units or neurons not only make their decisions based on data inputs from the real world and/or the decisions of other neurons at the current time, but take into consideration the probabilistic decisions and state of its neurons from earlier times. This means many things, each good and bad depending on the scenario. Now, not only can they make good or bad decisions, they can continue to make these good or bad decisions long after the stimulus or input has ceased to exist.  A bad decision doesn't just affect the current choice, but can continue to affect future decisions. Continue to improve on a good decision or worsen a bad decision. Learn from good examples just as well from bad examples. Make choices based on learnt probabilities of choices, learnt probabilities of right and wrong, learnt probabilities of good and bad.

A recurrent machine learning model, is one step closer to self conscious thought and decision making.

This might might sound more more like how we humans think. And you will be absolutely right. It is. That is exactly what current generation machine learning is trying to model. But the size and complexity of current generation neural networks is similar to that of the brain of a fly. But its growing and evolving every day. Now imagine something the size of a 1000 human brains, that can learn from every piece of data available to it from all across the world. And what it learns is based on what its taught, what data it sees and the conclusions it gleans from it. This is not a matter of if, any more, but when.

It took 16000 interconnected machines to recognize cats in a video, in an experiment by Google.  A year later it took 16 machines with GPU(graphics processing units) that are way smarter at arithmetic. So computing is not the barrier. The algorithms keep improving every year, learning machines officially have supervision i.e. they smarter than humans at least in some limited vision tasks and will be driving cars soon. In the machine learning world, if computing and the algorithm is the rocket, the data needed for them to learn from, is the rocket fuel, as one eminent machine learning scientist, Andrew Ng, put it in last weeks GPU Technology conference. And data is now available everywhere in spades, petabytes of it and growing exponentially.

In a such dynamic, probabilistic model, its learning driven by huge amounts of data, its decisions governed by a potentially long history of inputs and previous decisions, its learning potential and consciousness is limited only by the amount of computing power and data we throw at it.  For these systems, any choice or decision, even a murderous, destructive or even catastrophic one, does not have a zero probability, it just might have a very low probability.

And even that, we can't be sure of, because we truly can't understand what rules it has learnt, what their probability is or the exact sequence of events that could trigger that decision. That is truly what makes it both powerful and dangerous. You understand and control a nuclear reaction. But how do you control and risk manage something that is just as powerful, but you truly can't understand.

To summarize the big points of concerns to watch for

  1. Recurrent Learning Machines are closer to inventing self conscious intelligent thought than anything invented so far, and at this point we don't really even understand how close.
  2. Their level of intelligence is only limited by the amount of computing and data we throw at it. They certainly have the potential to surpass humans.
  3. It is theoretically not possible to understand all the rules it has learnt and how the rules translates to events in real life. Trying to understand the probability of every outcome for every possible sequence of events can be exponentially more complex. So this creates an inherent level of uncertainty and hence risk to the decisions that they make.
  4. The universal nature of this technology means that it can be applied to learn from a wide range of data and solve many problems. This means that it can eventually control very vitals parts of society and make decisions that are life or death. A technology that can become an integral part of life.
There isn't another technology in history that really compares to AI in these aspects and is pretty unique.

And let me be clear, the potential for a AI singularity is just the final big ticket catastrophic risk. There are many other intermediate risks and uncertainty, strewn all along that path as mine fields, that needs careful thought and consideration to navigate. They get riskier as the system gets more intelligent and intertwined with every aspect of our life.   

Now are we there yet, clearly and most definitely, not yet. None of the machine learning algorithms that exist today can do, what I claim they can do eventually. The technology is still in its infancy and its not clear how close we are to machines of such intelligence. We could be decades away or just a simple algorithm tweak away. But the key attributes I list about these learning machines all exist and are currently evolving. The direction they are evolving is clearly headed there.

So when truly smart people like Elon Musk and Bill Gates sound a warning, everyone should listen. Not to shut down research in this area all together.
But to start thinking about its dangers, and the needed checks and balances.

Make sure we recognize Pandora's Box from a mile away, let alone trying to open it. But have no doubt in your mind, that it truly has the potential to be Pandora's Box.

Saturday, December 21, 2013

My Machine Learning Tool Box

I've been meaning, for sometime, to write about everything science and technology that I am passionate about. What better way to kick it all off, than to talk about my machine learning development toolbox.

Programming Language

I believe the programming languages you use is one of the most key tools in your toolbox.  Why? Because it affects the way you develop code, from the simplicity of code in expressing the solution, the readability of the written code, the availability of libraries for the wide range of problems you might encounter, the productivity with which you can develop software and doing it all without trading off too much in performance when it matters. I also believe in a small but powerful toolbox that you are an expert at than a very large one. For an average developer like myself, I find it easier to be an expert of one or two languages than claim to have an average understanding of 10 languages. Hence I choose my languages in my tool box carefully.

Hence my tool box consists of the following

  1. Python
  2. C/C++
Python is a scripting language, that is comparable to perl and ruby but superior in many respects. It has the same level of expressive power as Perl, yet is way more readable which is very important in software development. Code gets read many more times than it is written and it is important that it is very readable. Its an interpreted language but also has JIT implementation available for performance. And when further performance is needed, it is easy to convert the performance critical code  in to C/C++ directly or using a tool like Cython as an assist. With libraries like CFFI it is easy to wrap C libraries and make them available for use from python. And the range of libraries and tools available in python is legendary, from web development, mathematics, scientific computing.


C/C++ is a compiled lower level language that allows me to implement sections of the code that need to be performant. Generally speaking, 90% of the performance problems can be narrowed down to 10% of the code. So my development philosophy has always been to write what i need in python and drop down to C/C++ to improve that 10% of the code where performance matters. There tools like Cython and CFFI that make it brain dead simple to do.  For the sort of the code where scripting language is not an option C/C++ will fill in the space completely.

Go language from google as a future alternative to C/C++ has potential. I am keeping an eye on it. I would like to see how it works and interfaces with python. And if it keeps improving like it has been, it probably will replace C/C++ in my toolbox

Development Environment

iPython is a more advanced python shell/development environment that allows you to develop faster. It supports functionality like the ipython notebook that provides a browser placed environment to experiment with code, generate and view graphs, etc. interactively from within the browser. Additionally, the code and generated graphs can be interspersed with documentation that makes it a great tool to communicate ideas or generate interactive documentation.

virtualenv/pip is a set of tools in python that allows you to create virtual private instances of the python installation, there by allowing you to do development of python modules without messing with the central installation. These virtual instances are very light weight. Further, pip a more advanced package management tool allows for a "development mode" install of the library you are developing which is convenient for development. It creates symlinks to your development directory from the python installation directory, thereby letting you modify your python sources and running them without any additional installation requirement.

CFFI is python wrapper generator for C code. This allows you to take any C library and generate a python wrapper to the C code from the C header files with little or no change.

Mayavi is a 3D scientific visualization tool with a python interface that is very handy to view error surfaces of neurons or neural networks.  It allows me to take training errors, neuron signals, etc as they evolve during training and have them plotted as 3D surfaces that give better visual understand of how things are performing or where the problems are. Understanding machine learning needs an understanding of how error surfaces behave during training.

Libraries

Numpy/SciPy  - Machine learning involves a lot of floating point vector arithmetic. A library like Numpy allows you to do fast vector arithmetic from python and has a full library of statistical and scientific formulae implemented and ready for use.

Pandas - Think of Pandas as filling the holes in Numpy when specifically dealing with Time Series data.

Hardware Acceleration

Theano - GPGPU Acceleration - When working machine learning algorithms, you will quickly find that it is very vector math intensive, meaning you are going to be doing vector calculations a lot. This means that you are soon going to hit the limits of your main CPU, even if it has many cores. Though many of the vector math libraries can make use of multiple CPUs to accelerate your machine learning algorithms, being able to leverage one or more GPGPU units you may have on the system will be indispensable. GPGPU stands for General Purpose Graphic Processing Units. These are graphic accelerators from vendors like NVidia. But graphic processing requires a lot of vector arithmetic and hence they have been designed to be good array/vector processors which is exactly what is needed for machine learning.

A python library like Theano allows you to express your machine learning formulae and have them compiled to run on the GPU and hence achieving 10-100 fold increase in performance. If a GPU is not available, it is smart enough to use vector acceleration libraries that can make use of multiple CPU cores to still get better performance from python.

The Future

There  is still a scale issue if you want to do really massive models that might involve distributed computing. The GPGPU are evolving to be networking capable and I hope in the future theano evolves to be able to distribute its computation across a cluster of GPGPU nodes.

Machine Learning involves developing mathematical models for neurons and neural networks as well creating networks of networks. It would be nice to have an object orient library where I can implement neuron and network models driven by the power of theano behind it. It would allow for a more intuitive experimentation with machine learning models and networks.

In general the language you are comfortable, the tools you like to use are all quite personal. Over the years I have tried many of the language choices including perl, tcl, java, bash, etc. and have settled to the once above for the near term. Technology does change rapidly and these choices might change in the future. But this is my machine learning toolbox as it stands now.

Saturday, November 30, 2013

Dry Rubbed, Honey Glazed, Slow Baked Chicken - A Thanksgiving Recipe

Most people cook a Turkey for Thanksgiving. But not everyone likes or eats turkey. So I made a dry rubbed, honey glazed, slow baked, chicken with crispy garlic bread and potato all in one dish.


Dry Rub Recipe - Make anytime and store
Ingredients
Salt - 1/3 cup
Jaggery - 4 - 1"x1/2"x1/2" pieces
Chilli powder - 7 tablespoons
Ground Pepper - 2 tablespoons
Allspice powder - 1 teaspoon
Garlic powder - 2 teaspoons
Ginger powder - 1 teaspoon
Cumin powder - 4 teaspoons
Onion powder - 2 tablespoons
Mustard powder - 2 teaspoons

Preparation
Mix and grind all dry rub ingredients into a coarse powder in a mortar or dry grinder. Store in a container until needed.


Marinading the Chicken - 12 hours
Keep the skin of the chicken intact and use a knife to separate the skin from the meat. Cut deep slits on the meat(not the skin). Sprinkle dry rub powder generously over the meat and massage into it the meat and slits. Rub the spice mix inside the chicken as well. Cover the meat by pulling the skin back over the meat. Sprinkle dry rub over the skin, as well. Place in a tray. Cover with plastic wrap and refrigerate for 12 hours.

Slow Baking the Chicken - 10 hours
Ingredients
Chicken, whole, with skin - 1
Bread - 8 slices
Potato, medium - 3 or 4
Fingerling potatoes(tiny) - 20
Garlic - 2 teaspoons
Onion powder - 1 tablespoons
Fresh Ground pepper - 3 teaspoons
Salt - 2 teaspoons
Chicken Stock - 1 cup
Lemon Juice - 1 tablespoon
Honey - 3 tablespoons
Vegetable Oil - 1 tablespoon

Preparation - 10 minutes
In a bowl mix garlic, onion powder, pepper, salt.
In a ceramic or glass baking tray, rub vegetable oil on the bottom. Layer with quarter inch slices of potatoes. Sprinkle the garlic/onion spice mix from the bowl over the sliced potatoes. Layer the sliced bread. Sprinkle some more of the garlic/onion spice mix from the bowl on top of the bread. Place the marinated chicken on top of the bread. Put the fingerling potatoes into the bowl, close and shake. Drizzle the vegetable oil into the bowl. Close and shake to coat evenly. Spread the fingerling potatoes around the chicken and put a couple inside it as well. Drizzle the liquid remaining in the bowl over the bread and potatoes.
Cover lightly with aluminium wrapper and a put a few knife slits into the wrapper.

Baking - 10 hours
Bake on the middle rack(not too close to the heat) at 200 degrees for 10 hours.  Increase temperature to 220 degrees for the last 2 hour and remove the foil. Mix the honey and lemon juice in a bowl and keep brushing the whole chicken every 1/2 hour. Add the chicken stock little by little into the sliced potatoes/bread to prevent them from drying too early.
When done at the end of 10 hours, the chicken skin, sliced potatoes, and bread should all be browned and crispy. The bread should not bet wet.

Serving
Let the bird rest for 10 minutes before carving. Serve a slice of the crusted potatoes and bread along with the fingerlings. Goes well with a bottle of medium bodied red wine.

Can be done with leg quarter of chicken as well for a smaller gathering.

Friday, September 13, 2013

Bongoo - My first rap song


He's a tease, my cheese,
My breath, my breeze,
The bee's knees, I love to squeeze,
My life's lease, across the 7 seas,
A hug, a kiss, and my spirit free's

He giggles, he squiggles,
When I hold him, he wiggles, he wriggles
Garbage cart, garbage cart, he niggles,
One gummy bear, no two, he tries and higgles,
What is this, what is that, everyday gets smarter, and riddles.

He's my workout, my mahout,
With whom I play out, till its lights out,
The reason, I don't washout, punch out, or feel like a copout,
The one I go to, when I burnout,
No doubt, the one I can't do without.

Every day I wandered, I sat on an pondered,
The meaning of life? I wept and wondered,
Searched far and wide and beyond the yonder,
Everyday and every night, I grow fonder,
I can tell you for sure, nothing in life grander.

Fly back, on a whim,  from Timbuktu,
Coz, I'll miss the way, he goes, Peekaboo,
Its black magic, its kung fu, no, jijutsu,
A smile, your defenseless, he subdues you,
My daily rendezvous with, the chatty, the naughty, the sidu bongoo.





Saturday, August 24, 2013

In search of a meaning for the words "I Love You"

Why do you feel all warm and fuzzy when a 2 year old says "I Vuv You". Incase you did'nt already get it, thats baby talk for "I Love You"

People say "I Love You" all the time.  Do they really mean "I love the way I feel when I am around you"?

A mother says "I Love You" to her kids. A child says "I Love You"  to the father. Friends, cousins, soul mates and lovers say it to each other. Ironically, so do stalkers, desperados and the crazies who won't let go.

But what do they really mean.  What do you really mean when you say "I love you" to someone and why do you say it. Why does it evoke such craving for more. Why do some even go nuts in its pursuit.

For, such a meaning must convey such varied emotions, apply to all ages, a range of relationships and be applicable to states of mind as different as day and night.

The search for a universal meaning for those 3 words together eluded me for while.

The definition of the word 'love', according to the dictionary, an intense feeling of deep affection, a person or thing that one loves, to feel a deep romantic sexual attachment. But none of it explained all.

And then I pondered the why and the how I feel when I say that to someone or when someone else says that to me. Why do people crave it. Even get obsessed and addicted to it. It made more sense.

It seems to make sense for all the times and places when people say those words. People want to feel good about themselves, have a good self image. And if people feel that way when they are with someone, it only makes sense that they want more of that feeling.

So now I think, when someone says those three words "I Love You", what they are really saying is "I love how I feel when I am with you".

Quite a few people pointed out or argued that this was a very selfish perspective. And that love is selfless, giving, unquestioning and boundless in nature and more.

I just wanted to clarify that I don't disagree with these characterizations of what love is and what it is capable of.  I have no doubt they are all these and possibly more. When you wonder about something like love, the answer you get also depends on the question you ask.  I was merely trying to ask the why?

Like a child, I kept asking myself, why? why? why? at every answer or reason I came up with, and this process kept returning to the self, the how or why the self felt the way it did.  Returning to ones own heart.

This may sound clinical and unromantic at first, to look at it from this perspective. It doesn't change the fact that the person that is the object of one's affection is the one that makes you feel and want to be a better person, a better mother, a father or a friend. It doesn't take away from it the fact, there are some innate or hard earned qualities about that person that makes you feel that way. That the way you feel may even be the emotional price you pay for those qualities.

But its undeniable that the why, eventually kept me coming back to one conclusion. That when we say "I love you" one really means "I love who I am and how I feel when I am around you"

Monday, May 20, 2013

Tandoori Chicken Sandwich with Grilled Onions, Chipotle Chilli and Avacoda


Ingredients

  • Sliced White Sandwich Bread
  • Leftover Tandoori Chicken (Refer to Tandoori Chicken Recipe)
  • 1 Chipotle Chilli
  • 1 large red onion
  • 1 avacado
  • 1 Tomato
  • A few Olives or Tepanade
  • 1/2 teaspoon chilli flakes
  • Dijon Mustard
  • Mayonaise
  • Pesto Sauce
  • Chipotle Cheddar slices




Steps

  1. Shred the left over Tandoori Chicken into small pieces
  2. Slice the red onions and Chipotle Chilli into thin long slices and saute in olive oil for 4-5 minutes until the onions translucent and chilli slices are soft. Keep aside
  3. Spread Dijon mustard whipped with chilli flakes on half the bread slices
  4. Spread Pesto Sauce on the other bread slices.
  5. Squirt a couple of strips of mayonaise on all the slices
  6. Layer the shreded chicken, sauted onions/chilli, a couple of thin slices of tomato, a couple of sliced olives or tepanade, a couple of thin slices of avocado, and top it with just a few bits of the chipotle Cheddar slices
  7. Close the sandwich the remaining bread slices and grill in a sandwich maker. If you don't have one you can grill it on a pan sprayed  with olive oil and placing a HOT and heavy cast iron pan on top of the sandwich  until both sides get toasted.
  8. Slice and serve

Sunday, April 28, 2013

Fried CatFish on bed of Cabbage, seasoned with Coconut and Poppy seeds


Ingredients

  • 2 teaspoons of Poppy Seeds
  • 2 teaspoons of Fennel
  • 2 teaspoons of Jeera
  • 1 1/2 tablespoon of Pepper corns
  • 10 Curry leaves
  • 1/3 can of coconut milk
  • 1/3 can of water
  • 1 medium sized Onion, chopped
  • 1 teaspoon of Garlic Paste
  • 2 medium sized tomatoes, chopped
  • 6 pieces of Cat fish, each about 2 inch squares
  • 1 quarter of medium sized Cabbage, chopped fine

Steps

  1. Grind the Poppy seeds, Pepper Corns, Jeera and Fennel seeds in dry grinder
  2. Heat the oil in a Tawa
  3. Put the Curry leaves in the hot oil for 30 seconds
  4. Add the ground powder from step 1 and fry for another minutes
  5. Add garlic and fry
  6. Add chopped onions an fry till the onions turn brown
  7. Add the tomatos and fry till the tomatos well
  8. Add coconut milk and equal amount of water and cook till the added water is gone
  9. Remove some of the sauce into a bowl, enough to batter the pieces of fish with
  10. Reduce the the gravy a bit further into a thick sauce
  11. Add the finely chopped cabbage and fry for 1 minute
  12. Take of the heat and transfer into a square serving plate
  13. Batter the pieces of fish in the gravy saved for battering in step 9
  14. Shallow fry in hot vegetable oil about 3 minutes each side
  15. Lay the fried fish on on the bed of cooked Cabbage