Last autumn Udacity and Facebook have announced PyTorch Scholarship Challenge. People from all over the world could apply to this scholarship and they did: there were ~18000 applications and 10000 of them were able to take part in this challenge.
This course was quite basic, so a lot of participants were able to complete it; but doing it wasn’t the only requirement of being selected as top-300 — contribution to the community was measured as well. There were a lot of activities — answering questions on slack, webinars, study groups and many others.
In the end I got to top-300 and was able to go through this Nanodegree!
I had already made several deep learning projects before these courses, but they were in TensorFlow or Keras and I wanted to learn PyTorch — so this Nanodegree was a wonderful opportunity to study it.
I plan to describe my experience in several blog posts.
I won’t post the whole code or go into details of each lesson — these posts are aimed at people who want to know what this course is about or to learn some specific things. On the other hand I’ll post direct links to videos with lessons (Udacity is okay with it) and write was was interesting to me.
By the way, all (or almost all) the code is available in this GitHub repo: https://github.com/udacity/deep-learning-v2-pytorch It includes exercises and solutions.
Let’s start with the introduction!
The first part is dedicated to introducing students to Udacity and showing the basics of deep learning and Python.
At first we are told about Udacity guidelines, support and the community.
The course structure is the following: feed forward neural nets, basic sentimental analysis and pytorch; CNN; RNN; GAN and deploying deep learning models on Amazon’s Sagemaker.
While working on the course we are supposed to implement five projects:
- Predicting Bike-Sharing Data
- Dog Breed Classifier
- Generate TV Scripts
- Generate Faces
- Deploy a Sentiment Analysis Model
Another interesting point is that we can use Career services and receive feedback on CV, LinkedIn profile and Github repository.
There are three short lessons on using Anaconda, Jupyter Notebooks and Numpy, but I’ll skip talking about them as I expect readers already know these topics. Instead I’ll focus on the lesson where we can see demonstration of some cool applications of deep learning!
Style transfer allows you to take one image and transfer its style to some other image. It is often used in apps for photos styling!
There will be a lesson dedicated to Style Transfer in CNN part, but we can play with Style Transfer right now.
We use this repo: https://github.com/lengstrom/fast-style-transfer
Here are the steps with which we can try Style Transfer:
- Install Tensorflow, Pillow, and SciPy, and moviepy. It can be done like this (after installing Anaconda):
conda create -n style-transfer python=3
conda activate style-transfer
conda install tensorflow scipy pillow
pip install moviepy
python -c "import imageio; imageio.plugins.ffmpeg.download()"
It is possible that the last line won’t work, simply replace it with:
pip install imageio-ffmpeg
2. Clone the repository or download it
3. Download the Rain Princess checkpoint from here. Put it in the fast-style-transfer folder. This is a trained model, which can be used to apply style transfer immediately.
4. Copy the image you want to style into the fast-style-transfer folder.
5. After this you can run style transfer using this command:
python evaluate.py --checkpoint ./rain-princess.ckpt --in-path <path_to_input_file> --out-path ./output_image.jpg
That’s it! :)
DeepTraffic (Reinforcement Learning)
While reinforcement learning is out of score of this course, it is still a cool application.
Here is the video about DeepTraffic. The network here is attempting to learn a driving strategy such that the car is moving as fast as possible using reinforcement learning. The network is rewarded when the car chooses actions that result in it moving fast. It’s this feedback that allows the network to find a strategy of actions for optimal speed.
FlappyBird with reinforcement learning
You have the option to train the agent yourself, but for now let’s just start with the pre-trained network given by the author.
We use this repository by Yenchen Lin.
Instructions from the lesson:
- Install miniconda or anaconda if you have not already.
- Create an environment for flappybird
conda create --name=flappybird python=2.7
conda create --name=flappybird python=3.5
3. Enter your conda environment:
conda activate flappybird
conda install opencv
pip install pygame
pip install tensorflow==0.12
If these steps were done correctly, you’ll see the agent playing the game! You can see more instructions and information in the repository.
Some books on Deep Learning:
- Grokking Deep Learning by Andrew Trask. This provides a very gentle introduction to Deep Learning and covers the intuition more than the theory.
- Neural Networks And Deep Learning by Michael Nielsen. This book is more rigorous than Grokking Deep Learning and includes a lot of fun, interactive visualizations to play with.
- The Deep Learning Textbook from Ian Goodfellow, Yoshua Bengio, and Aaron Courville. This online book contains a lot of material and is the most rigorous of the three books suggested.
That’s it for now! In the next blogpost, I’ll write about the second part — about basic neural nets.