Deep Learning With Python
Intro to Theano
Theano is a Python library for fast numerical computation to aid in the development of deep learning models. At its heart, Theano is a compiler for mathematical expressions in Python. It knows how to take your structures and turn them into very efficient code that uses NumPy and efficient native libraries to run as fast as possible on CPUs or GPUs. The actual syntax of Theano expressions is symbolic, which can be off-putting to beginners used to normal software development. Specifically, expression are defined in the abstract sense, compiled and later actually used to make calculations. In this lesson, your goal is to install Theano and write a small example that demonstrates the symbolic nature of Theano programs. For example, you can install Theano using pip as follows:
A small example of a Theano program that you can use as a starting point is listed below:
Intro to TensorFlow
Intro to Keras
A difficulty of both Theano and TensorFlow is that it can take a lot of code to create even very simple neural network models. These libraries were designed primarily as a platform for research and development more than for the practical concerns of applied deep learning. The Keras library addresses these concerns by providing a wrapper for both Theano and TensorFlow. It provides a clean and simple API that allows you to define and evaluate deep learning models in just a few lines of code. Because of the ease of use and because it leverages the power of Theano and TensorFlow, Keras is quickly becoming the go-to library for applied deep learning. The focus of Keras is the concept of a model. The life-cycle of a model can be summarized as follows:
Define your model. Create a Sequential model and add configured layers.
Compile your model. Specify loss function and optimizers and call the compile() function on the model.
Fit your model. Train the model on a sample of data by calling the fit() function on the model.
Make predictions. Use the model to generate predictions on new data by calling functions such as evaluate() or predict() on the model.
Your goal for this lesson is to install Keras. For example, you can install Keras using pip:
Crash Course in Multi-Layer Perceptrons
Artificial neural networks are a fascinating area of study, although they can be intimidating when just getting started. The field of artificial neural networks is often just called neural networks or multi-layer Perceptrons after perhaps the most useful type of neural network. The building block for neural networks are artificial neurons. These are simple computational units that have weighted input signals and produce an output signal using an activation function. Neurons are arranged into networks of neurons. A row of neurons is called a layer and one network can have multiple layers. The architecture of the neurons in the network is often called the network topology. Once configured, the neural network needs to be trained on your dataset. The classical and still preferred training algorithm for neural networks is called stochastic gradient descent. Your goal for this lesson is to become familiar with neural network terminology. Dig a little deeper into terms like neuron, weights, activation function, learning rate and more.
Develop Your First Neural Network in Keras
Load your dataset using NumPy or Pandas.
Define your neural network model and compile it.
Fit your model to the dataset.
Estimate the performance of your model on unseen data.
Use Keras Models With Scikit-Learn
The scikit-learn library is a general purpose machine learning framework in Python built on top of SciPy. Scikit-learn excels at tasks such as evaluating model performance and optimizing model hyperparameters in just a few lines of code. Keras provides a wrapper class that allows you to use your deep learning models with scikit-learn. For example, an instance of KerasClassifier class in Keras can wrap your deep learning model and be used as an Estimator in scikit-learn. When using the KerasClassifier class, you must specify the name of a function that the class can use to define and compile your model. You can also pass additional parameters to the constructor of the KerasClassifier class that will be passed to the model.fit() call later, like the number of epochs and batch size. In this lesson, your goal is to develop a deep learning model and evaluate it using k-fold cross validation. For example, you can define an instance of the KerasClassifier and the custom function to create your model as follows:
Plot Model Training History.
You can learn a lot about neural networks and deep learning models by observing their performance over time during training. Keras provides the capability to register callbacks when training a deep learning model. One of the default callbacks that is registered when training all deep learning models is the History callback. It records training metrics for each epoch. This includes the loss and the accuracy (for classification problems) as well as the loss and accuracy for the validation dataset if one is set. The history object is returned from calls to the fit() function used to train the model. Metrics are stored in a dictionary in the history member of the object returned. Your goal for this lesson is to investigate the history object and create plots of model performance during training. For example, you can print the list of metrics collected by your history object as follows:
Save Your Best Model During Training With Checkpointing.
Reduce Overfitting With Dropout Regularization.
Lift Performance With Learning Rate Schedules.
Crash Course in Convolutional Neural Networks.
Handwritten Digit Recognition.
Object Recognition in Small Photographs.
Improve Generalization With Data Augmentation.
Last updated