Hands-on-Intro-to-Auto-Diff
Hands-on-Intro-to-Auto-Diff copied to clipboard
A Hands-on Introduction to Automatic Differentiation
This is the code repository accompanying the two-parts blog posts series:
- A Hands-on Introduction to Automatic Differentiation - Part 1.
- Build Your own Deep Learning Framework - A Hands-on Introduction to Automatic Differentiation - Part 2
How to use the code
Before using the code, there are some requirements that needs to be present on your machine to run the code samples in the Jupyter notebooks. Some of these requirements are internal and can be easily fetched with Python's pip across the different platforms. Other requirements are external and needs to be fetched from other sources than Python's pip, and these sources usually differ based on your operating system. But fear not, it's quite simple to get them and you'll find the how-to instruction below.
Installing external requirements for the visualizations
For the code to work, we need to have both graphviz and ffmpeg to be installed on your machine. These packages are mainly concerned with the computational graph visualizations and the animated reverse automatic differentiation visualizations. We here provide the instructions on how to install them on Ubuntu, macOs, and Windows.
Installing graphviz
Ubuntu
- Simply run
sudo apt install graphviz
macOS
- Install Homebrew package manager.
- Run
brew install graphviz
Windows
- Download the .msi installer from graphviz website
- Run the installer.
- Locate the install location (which will probably be
C:\Program Files (x86)\GraphViz2.38) - Add
C:\Program Files (x86)\GraphViz2.38\binto yourPATHenvironment variable.
Installing ffmpeg
Ubuntu
- Simply run
sudo apt install ffmpeg
macOS
- Install Homebrew package manager.
- Run
brew install ffmpeg
Windows
- Download the windows static build from ffmpeg website, which is a zip file.
- Unzip the build file in your preferred location (Let it be
C:\Program Files (x86)\ffmpeg) - Add
C:\Program Files (x86)\ffmpeg\binto yourPATHenvironment variable.
Installing python requirements and running the code
this assumes that you have python3.5 installed on your machine and you know how to use Jupyter notebooks
- Make sure that you have the
virtualenvpackage by runningpip3 install virtualenv - Open the terminal at your local copy of this repository and create a fresh virtual environment with
python3 -m venv venv - Activate your new virtual environment with
source venv/bin/activate - Run
pip install -r requirements.txt - Install an IPython notebook kernel pointing to your virtual environment to use with the notebooks via
python -m ipykernel install --user --name AD - Fire up jupyter notebook with
jupyter notebookand start using the code.