tutor: temirlan zharkynbek elective in ai...
TRANSCRIPT
![Page 1: Tutor: Temirlan Zharkynbek Elective in AI …users.diag.uniroma1.it/~alcorlab/sites/default/files...Tensorflow This tutorial walks you through the process of building a simple CIFAR-10](https://reader035.vdocuments.net/reader035/viewer/2022071107/5fe1170957df0c50d55a655c/html5/thumbnails/1.jpg)
Elective in AITensorflow: TensorFlow 2.0 Tutorial
Tutor: Temirlan Zharkynbek
![Page 2: Tutor: Temirlan Zharkynbek Elective in AI …users.diag.uniroma1.it/~alcorlab/sites/default/files...Tensorflow This tutorial walks you through the process of building a simple CIFAR-10](https://reader035.vdocuments.net/reader035/viewer/2022071107/5fe1170957df0c50d55a655c/html5/thumbnails/2.jpg)
Tensorflow 2.0x
Pagina 2
![Page 3: Tutor: Temirlan Zharkynbek Elective in AI …users.diag.uniroma1.it/~alcorlab/sites/default/files...Tensorflow This tutorial walks you through the process of building a simple CIFAR-10](https://reader035.vdocuments.net/reader035/viewer/2022071107/5fe1170957df0c50d55a655c/html5/thumbnails/3.jpg)
Example #1: from official webpage of Tensorflow
Pagina 3
![Page 4: Tutor: Temirlan Zharkynbek Elective in AI …users.diag.uniroma1.it/~alcorlab/sites/default/files...Tensorflow This tutorial walks you through the process of building a simple CIFAR-10](https://reader035.vdocuments.net/reader035/viewer/2022071107/5fe1170957df0c50d55a655c/html5/thumbnails/4.jpg)
tf.function
Pagina 4
![Page 5: Tutor: Temirlan Zharkynbek Elective in AI …users.diag.uniroma1.it/~alcorlab/sites/default/files...Tensorflow This tutorial walks you through the process of building a simple CIFAR-10](https://reader035.vdocuments.net/reader035/viewer/2022071107/5fe1170957df0c50d55a655c/html5/thumbnails/5.jpg)
Training
Pagina 5
![Page 6: Tutor: Temirlan Zharkynbek Elective in AI …users.diag.uniroma1.it/~alcorlab/sites/default/files...Tensorflow This tutorial walks you through the process of building a simple CIFAR-10](https://reader035.vdocuments.net/reader035/viewer/2022071107/5fe1170957df0c50d55a655c/html5/thumbnails/6.jpg)
Use tf.GradientTape to train the model:
Pagina 6
![Page 7: Tutor: Temirlan Zharkynbek Elective in AI …users.diag.uniroma1.it/~alcorlab/sites/default/files...Tensorflow This tutorial walks you through the process of building a simple CIFAR-10](https://reader035.vdocuments.net/reader035/viewer/2022071107/5fe1170957df0c50d55a655c/html5/thumbnails/7.jpg)
tf.function (explanation 1)
Pagina 7
![Page 8: Tutor: Temirlan Zharkynbek Elective in AI …users.diag.uniroma1.it/~alcorlab/sites/default/files...Tensorflow This tutorial walks you through the process of building a simple CIFAR-10](https://reader035.vdocuments.net/reader035/viewer/2022071107/5fe1170957df0c50d55a655c/html5/thumbnails/8.jpg)
tf.function (explanation 2)
Pagina 8
![Page 9: Tutor: Temirlan Zharkynbek Elective in AI …users.diag.uniroma1.it/~alcorlab/sites/default/files...Tensorflow This tutorial walks you through the process of building a simple CIFAR-10](https://reader035.vdocuments.net/reader035/viewer/2022071107/5fe1170957df0c50d55a655c/html5/thumbnails/9.jpg)
tf.GradientTape (explanation)
Pagina 9
![Page 10: Tutor: Temirlan Zharkynbek Elective in AI …users.diag.uniroma1.it/~alcorlab/sites/default/files...Tensorflow This tutorial walks you through the process of building a simple CIFAR-10](https://reader035.vdocuments.net/reader035/viewer/2022071107/5fe1170957df0c50d55a655c/html5/thumbnails/10.jpg)
Tensorflow
This tutorial walks you through the process of building a simple CIFAR-10 image classifier using deep learning. In this tutorial, we will:
● Define a model● Set up a data pipeline● Train the model● Accelerate training speed with multiple GPUs● Add callbacks for monitoring progress/updating learning schedules
Pagina 10
![Page 11: Tutor: Temirlan Zharkynbek Elective in AI …users.diag.uniroma1.it/~alcorlab/sites/default/files...Tensorflow This tutorial walks you through the process of building a simple CIFAR-10](https://reader035.vdocuments.net/reader035/viewer/2022071107/5fe1170957df0c50d55a655c/html5/thumbnails/11.jpg)
Defining a model
Pagina 11
![Page 12: Tutor: Temirlan Zharkynbek Elective in AI …users.diag.uniroma1.it/~alcorlab/sites/default/files...Tensorflow This tutorial walks you through the process of building a simple CIFAR-10](https://reader035.vdocuments.net/reader035/viewer/2022071107/5fe1170957df0c50d55a655c/html5/thumbnails/12.jpg)
Setting up a data pipeline
Pagina 12
● Loading: Copying the dataset (e.g. images and labels) from storage into the program's memory.
● Preprocessing: transforming the dataset. For example, in image classification, we might resize, whiten, shuffle, or batch images.
● Feeding: shoveling examples from a dataset into a training loop.
![Page 13: Tutor: Temirlan Zharkynbek Elective in AI …users.diag.uniroma1.it/~alcorlab/sites/default/files...Tensorflow This tutorial walks you through the process of building a simple CIFAR-10](https://reader035.vdocuments.net/reader035/viewer/2022071107/5fe1170957df0c50d55a655c/html5/thumbnails/13.jpg)
The tf.data.Dataset class
Pagina 13
The TensorFlow Dataset class serves two main purposes:
● It acts as a container that holds training data.● It can be used to perform alterations on elements of the training data.
![Page 14: Tutor: Temirlan Zharkynbek Elective in AI …users.diag.uniroma1.it/~alcorlab/sites/default/files...Tensorflow This tutorial walks you through the process of building a simple CIFAR-10](https://reader035.vdocuments.net/reader035/viewer/2022071107/5fe1170957df0c50d55a655c/html5/thumbnails/14.jpg)
Data augmentation
Pagina 14
Let's augment the CIFAR-10 dataset by performing the following steps on every image:
● Pad the image with a black, four-pixel border.● Randomly crop a 32 x 32 region from the padded image.● Flip a coin to determine if the image should be horizontally flipped.
![Page 15: Tutor: Temirlan Zharkynbek Elective in AI …users.diag.uniroma1.it/~alcorlab/sites/default/files...Tensorflow This tutorial walks you through the process of building a simple CIFAR-10](https://reader035.vdocuments.net/reader035/viewer/2022071107/5fe1170957df0c50d55a655c/html5/thumbnails/15.jpg)
Blocks of the Residual Networks (ResNet)
Pagina 15
![Page 16: Tutor: Temirlan Zharkynbek Elective in AI …users.diag.uniroma1.it/~alcorlab/sites/default/files...Tensorflow This tutorial walks you through the process of building a simple CIFAR-10](https://reader035.vdocuments.net/reader035/viewer/2022071107/5fe1170957df0c50d55a655c/html5/thumbnails/16.jpg)
Training the model and #GPU
Pagina 16
A Keras model needs to be compiled before training. Compilation essentially defines three things: the loss function, the optimizer and the metrics for evaluation:
![Page 17: Tutor: Temirlan Zharkynbek Elective in AI …users.diag.uniroma1.it/~alcorlab/sites/default/files...Tensorflow This tutorial walks you through the process of building a simple CIFAR-10](https://reader035.vdocuments.net/reader035/viewer/2022071107/5fe1170957df0c50d55a655c/html5/thumbnails/17.jpg)
Setting up a data pipeline
Pagina 17
● Loading: Copying the dataset (e.g. images and labels) from storage into the program's memory.
● Preprocessing: transforming the dataset. For example, in image classification, we might resize, whiten, shuffle, or batch images.
● Feeding: shoveling examples from a dataset into a training loop.
![Page 18: Tutor: Temirlan Zharkynbek Elective in AI …users.diag.uniroma1.it/~alcorlab/sites/default/files...Tensorflow This tutorial walks you through the process of building a simple CIFAR-10](https://reader035.vdocuments.net/reader035/viewer/2022071107/5fe1170957df0c50d55a655c/html5/thumbnails/18.jpg)
Tensorboard & Learning rate schedule
Pagina 18
![Page 19: Tutor: Temirlan Zharkynbek Elective in AI …users.diag.uniroma1.it/~alcorlab/sites/default/files...Tensorflow This tutorial walks you through the process of building a simple CIFAR-10](https://reader035.vdocuments.net/reader035/viewer/2022071107/5fe1170957df0c50d55a655c/html5/thumbnails/19.jpg)
Model fit
Pagina 19
![Page 20: Tutor: Temirlan Zharkynbek Elective in AI …users.diag.uniroma1.it/~alcorlab/sites/default/files...Tensorflow This tutorial walks you through the process of building a simple CIFAR-10](https://reader035.vdocuments.net/reader035/viewer/2022071107/5fe1170957df0c50d55a655c/html5/thumbnails/20.jpg)
References
Pagina 20
● https://lambdalabs.com/blog/tensorflow-2-0-tutorial-01-image-classification-basics/
● https://github.com/tensorflow/docs/blob/master/site/en/tutorials/quickstart/advanced.ipynb