Deep learning fundamentals – logistic regressions

12 Feb 2017

Logistic Regression

This blog captures an intuitive understanding of concepts such as Regression analysis required for deeplearning.

The following are summary of my notes from week 1 of the Udacity Deep Learning course.

Linear regression

is used to model the relationship between a dependent variable and an independent variable. The intent is to draw a line through your data that best fits your data. This line is then used to predict a value when a new point lands in. Linear regression only works for data that is linear and is sensitive to outliers.

Example: I could model life expectancy of an individual based on BMI of the individual if I had built out a model of BMI —> Life Expectancy

Multiple linear regressions

While linear regression modelled a relationship between 1 independent variable and 1 dependent variable, multiple linear regression factors in other independent variables as well.

Example: The previous example is highly simplistic in assuming that we can predict life expectancy of an individual based on BMI only. However, if we do add heart rate data as an independent variable, we are likely to classify the data much more accurately.

Logistic Regression

is a regression model where the dependent variable can only have two output values “pass/fail”, “alive/dead”. I am going to use an example from the Udacity course.


A college admissions office looks at the grades and test results of an individual to accept or reject the person in the university. In the sample picture attached to the blog, every one who is green has been accepted to the university in the past while everyone on the red has been rejected.

This data splits very cleanly and doesn’t really require a neural network to predict acceptance/rejection of a new student. We will make this more complex as we go to the next example.

Teach a program to paint like Van Gogh

02 Feb 2017


There are some things that completely blow your mind. Applying artist specific styles to images is one of them. Completely sci-fiction – although the Prisma filter has made this accessible.

In the last blog, I set up the core software requirements for the Udacity deeplearning course. This blog uses the setup to transfer the styles of 3 famous paintings and apply it to images.

It takes ages for an artist to come to a signature style. It takes longer for another to mimic the style and I cannot fathom if a mimic can apply the style to different images. Deep learning does it with panache. Impressive! I am a convert.

I used the project called fast-style-transfer and ran the following command on an image to produce an output.

# creating a sandbox environment for python
conda create -n style-transfer python=3.5
source activate style-transfer
conda install -c conda-forge tensorflow=0.11.0
conda install scipy pillow

# doing style transfer
python --checkpoint ./rain-princess.ckpt --in-path  --out-path ./output_image.jpg

Pictures to be stylised

Untitled Untitled

The original artwork:

The Wave by Kanagawa


Scream by Edward Munch


Rain Princess by Leonid Affremov


The modified images


Untitled Untitled


Setting up Anaconda for deep learning

28 Jan 2017


This blog sets up the core software requirements for the Udacity deeplearning course to get you started quickly.

I have just signed up for the deeplearning course and am fairly excited about it. The course heavily depends on Python – I used Python about 18 years back and have been a java guy since. The course requires you to setup Python 3.5, a number of data packages as part of Anaconda (a data science platform for analytics).

Rather than struggle with requirements on my Mac again and again, I have setup a docker image that is up-to date with all the core requirements for this coursework. Here is what you need to do get the docker image and run jupyter (which is wiki system for data analysis).

   docker run -i -t -p 8888:8888 hsingh/anaconda-deeplearning
   cd /home/jupyter
   jupyter notebook --ip='*' --port=8888

To bring up the Jupyter notebook, go to your browser on the host machine and enter