This repository contains the hands-on introductory deep learning tutorial examples for the Deep Learning for Science school at Berkeley Lab: https://dl4sci-school.lbl.gov/
These jupyter notebooks come from the official TensorFlow 2.0 tutorials at https://www.tensorflow.org/beta.
We made minor updates so attendees could run them on Cori GPU without modification.
Open https://jupyter-dl.nersc.gov/ and log in with your training account credentials.
Start a terminal by scrolling to the bottom of the Launcher window and clicking
the Terminal
button under Other
.
Using the terminal, clone this repository to download all of the tutorial notebooks:
git clone https://github.com/NERSC/dl4sci-tf-tutorials.git
Now you can use the Jupyter file browser to navigate the repository and launch notebooks.
You can test that things are working on a Cori GPU node by running the Test.ipynb notebook.
If you have issues with Cori GPU or if you simply prefer you can run these
examples in the cloud on Google's Collab service. Simply go to the TF webpage
for the specific example (links below) and click Run in Google Collab
.
Note that you may not get access to a GPU on Collab, but the TF tutorials are
designed to execute quickly regardless.
For a good introduction to implementing models in TensorFlow using the recommended Keras API, we recommend working through at least the first few examples below.
The overfitting/underfitting and save/restore examples also demonstrate very practical use-cases that you may want to work through.
Finally, depending on time, you can also try out the advanced examples according to your preference.
For each example, see if you can successfully modify the code and take note of how results change.
https://www.tensorflow.org/beta/tutorials/keras/basic_classification
Quiz questions:
- Why did we divide the image data by 255?
- Which activation function did we use for our hidden layer of the network? Could we have used a different one?
- Which activation function did we use for the output layer of the network? Could we have used a different one?
Challenges:
- Try to modify the network architecture by adding/removing layers, changing the size of the layers, etc.
- Try changing the optimizer algorithm; can you figure out how to modify the default learning rate?
- See if you can improve the test set accuracy. How good of a model can you train?
https://www.tensorflow.org/beta/tutorials/images/intro_to_cnns
This example is similar to the previous one but demonstrates how to setup CNNs so is valuable to work through as well.
Quiz questons:
- What benefit do we get from using max-pooling in our network?
- Why do we add the dense layers only at the end?
- Does the model converge with the specified settings?
Challenges:
- Try to modify the network architecture: the number of layers, the number of filters in the layers, the sizes of the filters, etc.
- What's the best test accuracy you can achieve?
- See if you can add data augmentation like the examples here: https://keras.io/preprocessing/image/
- Try to add BatchNormalization to the model: https://www.tensorflow.org/versions/r2.0/api_docs/python/tf/keras/layers/BatchNormalization
https://www.tensorflow.org/beta/tutorials/keras/feature_columns
Quiz questions:
- This tutorial is just meant to teach you some mechanics and doesn't give an impressive result. What are some of the reasons why this model under-performs?
- What are the situations in which you should consider using embedding or hashed-feature columns? Can you think of a good use-case for bucketized features?
https://www.tensorflow.org/beta/tutorials/keras/overfit_and_underfit
Quiz questions:
- Try to summarize how you diagnose under- and overfitting.
- If your model is overfitting, what is the most ideal way to improve it?
- How can you fix under-fitting?
Challenge:
- All the models in this example are overfitting. Can you build a model that underfits?
https://www.tensorflow.org/beta/tutorials/keras/save_and_restore_models
https://www.tensorflow.org/beta/tutorials/eager/custom_layers
https://www.tensorflow.org/beta/tutorials/load_data/images
https://www.tensorflow.org/beta/tutorials/generative/dcgan
https://www.tensorflow.org/beta/tutorials/generative/cvae
https://www.tensorflow.org/beta/tutorials/generative/cyclegan
Note: I didn't have time to install tensorflow-examples, so this is done in the notebook.
You will have to restart the kernel after running the pip install
cell to pick up the new library.
https://www.tensorflow.org/beta/tutorials/text/transformer
https://www.tensorflow.org/beta/tutorials/text/image_captioning
This example takes quite a while to run. It uses a fairly slow feature caching method, and the model training has poor GPU utilization and takes a while.
If you'd like to try TensorBoard in Jupyter, you can take a look at the example code in test_tensorboard.ipynb. See if you can get TensorBoard working with one of the example notebooks!