Skip to main content

Installing the Tools

We'll continue our descent by installing the tools necessary to conduct deep learning. The tools will include R, MXNet (framework for building neural nets in R), Python, and Tensorflow (framework for building neural nets in Python). You might ask why I'm using 2 different languages and 2 different frameworks. Truth be told, I like the way MXNet does classic, feed-forward neural network classifiers. You'll see that the syntax is concise and doesn't require as much fiddling with formatting of data. Unfortunately, MXNet doesn't exhibit the same elegance for more complex network architectures that we'll encounter later in this blog, so we'll use Tensorflow for CNN's (Image classification) and RNN's (time series classification).

So let's install R. First, we'll go to https://cran.r-project.org/bin/windows/base/ to download the latest version of R on Windows:
We'll click the "Download R 3.4.2 for Windows" link to download R (if you're reading this in the distant future, perhaps the R version would change but it likely wouldn't alter the pipeline for installing MXNet too drastically). 

Click through the installer and accept the default settings, and R will automagically be installed: 
Once that's done, we can install RStudio from https://www.rstudio.com/products/rstudio/download/#download. We'll download the latest installer for Windows 10, which can be found by scrolling down a little bit: 
We'll run the installer for RStudio, accepting all the default settings:

A quick aside about the roles of RStudio and R since I don't expect those reading this blog to have extensive statistical proficiency. RStudio is an IDE for programming in R that allows a more intuitive view of datasets we'll be working on and facilitates easy package installation. R is a popular statistical programming language and framework used pervasively in academia. R has packages, like MXNet, which contain pre-built functions that implement functionalities so that we don't have to, such as building a neural network, applying matrix operations, and calculating gradients.

Given that we didn't do anything wrong, we should be able to start up R Studio:
Now we'll install MXNet by executing these 4 lines in RStudio's console:
RStudio will then download a whole bunch of different files (MXNet has a lot of dependencies) and install the package for you. It's really quite magical. After MXNet is successfully installed, you'll see something like this:
At this point, we can really start doing some deep learning. But instead, I'm going to install Python and Tensorflow because we already have our installation caps on. So let's go https://www.python.org/downloads/ and download an installer for the latest version of Python: 
If we click the download link and scroll down a bit, we can see the download link for an executable installer for Windows. Let's download that: 
And once we run it, choosing the default setting as always, we should see:
To verify its installation, we can attempt to open IDLE. Go ahead and run it by searching your programs and you should be able to open IDLE. IDLE is the very minimal IDE we'll use for programming in Python. It looks like this, although you may have a different color scheme:
To install Tensorflow, we'll have to open a command prompt and execute the following command: 
Pip will download a whole bunch of packages that Tensorflow depends on and should say this upon a successful installation:
We can also verify that Tensorflow was installed correctly by importing it in the IDLE console: 
The console didn't scream any errors at us, which means that the installation was successful. 

So at this point we have all the tools we need to train neural networks. In the next post, I'll attempt to perform a task that was previously discussed in this blog: accurately classifying flower species by their sepal and petal lengths and widths. After that we'll probably get into things that are more interesting.

Comments

  1. I think it's very cool that you can do deep learning on your own with these tools. I have experience with R and Python, so I'm eager to see how these work together to build a neural network.

    ReplyDelete
  2. I can't wait to see where this goes; this is not a topic we go into deeply in most classes. Being interested in AI of all kinds, and knowing that neural networks are the basis for many of these newer kind, it is great to learn more about deep learning and building such networks.

    ReplyDelete

Post a Comment

Popular posts from this blog

Classifying Flowers Part 1: Data

Everybody loves plants. So we'll continue our descent by building a neural network that can do something with plants. This construct will be able to take characteristics that describe a plant and, if we're good enough, hopefully the neural network will be able to tell us with accuracy what type of plant it is. To do this, we'll use the Iris flowers dataset, which contains 150 samples of 3 different species (50 samples each). The species in this dataset are Iris setosa, Iris versicolor, and Iris virginica. The dataset can be found at the following links. Data:  https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data ReadME:  https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.names Here's a screenshot of the data we'll be working with: Initially, this data doesn't look too exciting and if it at all confuses you, you're perfectly normal. But we can figure some immediate information just from looking at the format ...

Classifying Flowers Part 2: Training and Evaluation

In the previous post, we fiddled with data and set out for an ambitious task of classifying plants. We ended that post after having downloaded, prepared, and partitioned our data, resulting two non-overlapping sets of data: a test set and a training set. We'll continue now by building, training, and evaluating a neural network to classify these flowers. First, we'll need to separate the values that we'll use as input to the network from the values we're intending to use as the output from the network. In other words, we need to place all the sepal and petal widths and lengths into a bag that the network can read, and all the species corresponding to the individual sets of sepal and petal widths and lengths into another bag. That way, when the network trains, it only takes into account the 4 inputs. When it produces an output, we can use the other bag (the one with species inside) to see if the network has predicted the species correctly. Before doing that, we'...

Evaluating our Heart Disease Classifier

Let's continue our descent by evaluating how good our heart disease classifier is. We can do this by generating predictions on the test set and see how the predictions compare to the test set's ground truth labels. That can be done with the following lines of code: At the bottom we can see that the classifier predicted 24 true negatives, 9 false positives, 8 false negatives, and 19 true positives. That's pretty okay. There is obviously some inaccuracy in the predictions, but let's calculate the accuracy anyways. (24+19)/(24+19+8+9)=71.6. So the test accuracy was 71.6, while, if you recall from the last post, the training accuracy was nearing 90%. This disparity between training and testing accuracy is a result of overfitting. Essentially, 50,000 training loops was too much training for this little of data. The resulting network overfit to the noise inherent in the training data and, as a result, failed to generalize as well on the test set. Therefore, the testing...