AISaturdayLagos: Ancestral Intelligence (AI) with Granny Theano

Tejumade Afonja
AI Saturdays
Published in
5 min readMar 23, 2018
Theano, wife of Greek philosopher and mathematician Pythagoras

The Theano library is supposedly named after the wife of the ancient Greek philosopher / mathematician, Pythagoras and Theano has really lived up to that reputation (ancient, just as Pythagoras himself).

Wow! it’s week 11/16 already 😲. Time does indeed flies.

We started Deep learning for coders Part 2 this week where we took a deep dive into artistic style transfer. For the afternoon session, we saw a lecture on Recurrent Neural Network. Thanks to Azeez Oluwafemi for leading the technical discussions.

#teamTheano’s presentation — 🔥

Below is an overview of #teamTeano’s experiments with Theano and MNIST dataset.

This section was put together by Tayo Jabar a team member of #teamTheano but it’s a collaboratory effort from the whole crew 🔥 🔥. You can check his post out here.

How this article is structured:

  1. Theano Documentation
  2. Installation
  3. Implementation
  4. Conclusion

Theano Documentation

As we all know, the first step to attacking a Deep Learning library is its documentation. Luckily, Theano documentation has a pile of information in its documentation page useful for any Theano beginner.

We started studying Theano’s documentation and it was really tedious and boring. At page 50/644 of the documentation, we asked ourselves “what the heck are we doing with this library?”.

Here is the link if you want to read https://media.readthedocs.org/pdf/theano/latest/theano.pdf ( knock yourselves out 😜 ).

The documentation made rumors of Theano being only for academia. It ensures that its users have a strong mathematical thought process.

Theano is a combination of the best features of Numpy and Sci-Py kits. It was built to understand the machine level process to implementing AI algorithms such that a typical Theano compiler can produce C and C++ code. Little wonder its name is associated with the Greek mathematician.

Installation

These are the basic requirements to have Theano installed on your machine.

  • NumPy >= 1.9.1 <= 1.12
  • SciPy >= 0.14 < 0.17.1
  • Conda (Recommended)
Run on Anaconda prompt

You should also note the following:

  1. Python 2.7* or >= 3.4 and < 3.6 — The development package (python-dev or python-devel on most Linux distributions) is recommended.
  2. Python 2.4 was supported up to and including the release of Theano 0.6.
  3. Python 2.6 was supported up to and including the release of Theano 0.8.2.
  4. Python 3.3 was supported up to and including release 0.9.

Implementation

We had enough of the documentation and were set to get our hands dirty and also after successfully installing the library on our machine, we went ahead to try out some of its functions such as its data types, shared variables, gradient calculation, updates, theano.function. One funny thing about Theano is its numerous data types. This is actually interesting, but we seemed not to find its use in application.

Explicit Datatype specification in Theano

To the main activity, we tried out the “hello world’ of image recognition; the MINST dataset. We implemented a logistic regression model on Theano and trained it using the MINST dataset.

Logistic Regression classified the images by presenting data points onto a set of hyperplanes, using the distance to determine a class membership probability and it was really nice to see old granny Theano working.

With a built-up morale, we went ahead to implement a simple neural network using the LeNet architecture as described in its documentation and the library worked fine without errors. We got an accuracy of 87%.

Simple illustration of the LeNet5 Architecture

Below is the link to the source code. (Sure be kind to drop comments on how to better this)

At this point, we felt we already had Theano in our palms. We confidently left the pond and headed for the ocean in search of a wild fish. We decided to implement VGG16 on Theano.

We though we had arrived
Theano be looking at us like

3 hours (sleepless night) into extensive research on how to incorporate transfer learning for image classification on Theano, we discovered we had become web archaeologists. There were no pre-trained models on the internet that we could use for this practice.

Teju see what you caused now o

Still left with some morale to spend, we decided to build a VGG model from scratch (how awesome is that) and train it with ?? dataset. The coding was quite easy and we expected it to work fine. But instead, the results were cryptic errors which had no pointer to its cause.

Mother Theano sure enjoyed the tough time she gave us

We tried to debug the error for hours until we finally gave up on Theano as a whole.

Conclusion

● Theano is actually a nice library to try out but it is definitely not a library to specialise on.

● Theano is more academia suited than for industry

● In as much as it one of the founding libraries for ML and DL practice, better libraries which are more concise, less stressful and require less coding have emerged e.g TensorFlow, Pytorch etc. so, use them instead.

#TeamTheano

Ultimately, this was a team effort 💪 and this experience is only the beginning of bigger things to come from #TeamTheano (we are definitely dropping Theano as a framework but sticking with the name though).

Thanks to:

  1. Simeon Ubi (Team lead) @ubietorbe
  2. Lawrence Francis
  3. Eseme Omole @esemejeomole
  4. Tayo Jabar @EnigmaticMe_
  5. Kenechi Dukor @kennydukor
  6. Udeme Udofia @udemeudofia
  7. Segun Adeleye @MrSegunAdeleye
  8. Olamiposi Olorunsola @olamiBounty
  9. Omoloye Adesina @omoloyeadesinak

Our newest member too, Segun’s yet-to-be-named baby boy whom we shall call Baby Theano (Theano indeed working miracles)

We applaud #teamTheano for taking up the challenge to learn about one of the most challenging deep learning framework. Kudos to the crew 👊.

AISaturdayLagos wouldn’t have happened without my friend & fellow ambassador, Azeez Oluwafemi, our Partners FB Dev Circle Lagos, Vesper.ng and Intel.

A big Thanks to Nurture.AI for this amazing opportunity.

Also read how AI Saturdays is Bringing the World Together with AI

See you next week 😎.

Links to Resources

https://drive.google.com/file/d/1OpGokNec4LuT41ZmojePeRKWGAs36378/view?usp=sharing

Stanford CS class CS231n: Convolutional Neural Networks for Visual Recognition.

Fastai framework.

Practical deep learning for coders

Deep learning Theories

Convolutional Neural Networks

A friendly introduction to Convolutional Neural Networks and Image Recognition

Setting up Google Colab 1

Setting up Google Colab II

--

--