This is a repository for the lab sessions of the following course: http://ispac.diet.uniroma1.it/scardapane/neural-networks-for-data-science-applications/
The course uses TensorFlow 2.0, moving from its core library of linear algebra up to the use of complex layers for image and audio applications.
It describes the linear algebra core of TensorFlow 2.0, before moving on to automatic differentiation with tf.GradientTape and a simple example of gradient descent.
[See online on nbviewer] - [Direct download]
We use the low-level API of TensorFlow to implement a simple linear regression algorithm. Then, we extend the example to binary classification by substituting some of our previously-defined functions with the tf.keras equivalents.
[See online on nbviewer] - [Direct download]
We build a feedforward neural network, this time on a realistic binary classification problem (prediction of super-symmetric particles from simulated measurements of a particle collider). We consider the use of tf.data to iterate on the dataset, and tf.keras.layers to actually build the model.
[See online on nbviewer] - [Direct download]
We train a VGG convolutional neural network on a dataset released for the In Codice Ratio (ICR) project. The dataset considers optical character recognition on Latin handwritten characters, segmented from a portion of the Vatican Secret Archives. We introduce tf.layers, keras.Model, and the ImageDataGenerator, along with callbacks and the TensorBoard.
[See online on nbviewer] - [Direct download]
We build from scratch multiple CNNs (including among their layers batch normalization, dropout, and residual connections), with regularization and a custom initialization function, on a toy autonomous driving task. We show how to create a flexible image pipeline with tf.data, and how to improve code efficiency with tf.function.
[See online on nbviewer] - [Direct download]
We build several text classification models on the IMDB reviews dataset: (i) a linear classifier with pre-trained embeddings; (ii) a linear classifier with learned word embeddings and manual tokenization; (iii) a convolutional neural network with learned embeddings. We also introduce TensorFlow Datasets and TensorFlow Hub.
[See online on nbviewer] - [Direct download]
A series of examples on how to use recurrent neural networks: first by counting symbols, then by building a more elaborate encoder/decoder architecture for sorting. We also introduce a series of important layers (Masking, TimeDistributed), and the padded batch from the tf.data.Dataset object.
[See online on nbviewer] - [Direct download]
We evaluate the robustness of a trained CNN on a simple adversarial attack using the IBM Adversarial Robustness 360 Toolbox. Then, we explore the problem of interpretability with tf-explain and LIME.