Docsity

Deep Learning - Artificial Intelligence Systems, Sbobinature di Machine learning

Toggle sidebar
bg1
MACHINE LEARNING (mod. 2)
1 - INTRODUCTION
Everything started in 1966 with The Summer Vision Project, an attempt in the reconstruction of a
significant part of a visual system. We can see the timeline of the evolution of this field. At the
beginning people started with analyzing two dimensional signals, and that the so-called Digital Image
Processing. Later was developed the Optical Flow, that actually is a process for computing what is
happening in a scene in terms of motions (of pixels). Going ahead, we can see the Kalman filters,
basic technique to track blobs objects in a scene. All the techniques till 2004 were either filter-based
or rule-based. In 2002 started the so-called Learning, that represent a massive changing in this field,
like machine learning fell in love with computer vision and a lot of things became possible. We can
see some examples of improvement in this field, like the pedestrian detection (e.g., providing some
good features with Histogram Of Oriented Gradient to Support Vector Machines), face detection
(using Viola-Jones method for comparing local blocks in an image, and so on. Since 2012, we saw
the transition from machine learning to deep learning in computer vision, because it was demonstrated
that deep learning technique was stronger than machine learning. We can see the relationship between
AI, ML and DL; artificial intelligence is the big discipline that has been invented first, whose idea
was to create computers that simulate the human intelligence; then inside artificial intelligence you
have several areas and machine learning is one of them and the difference between a general artificial
intelligence technique is that the machine learning is a subset of technique where you have a training
set and you want to discover regularities from this, and then you want to learn a model transferring
what you have learned to another dataset (test set); with deep learning we are still restricting the space.
There exist a lot of definitions this 3 fields, like the one given by John McCarty about AI who said
that “the objective is to make programs that learn from their experience as effectively as humans do”,
or the definition of ML by Arthur Samuel that “is the science of getting computers to act without
being explicitly programmed”, or about DL’ fathers (Y. Bengio, G. Hinton, Y. LeCun) published a
paper Nature giving its first definition: “DL allows computational models that are composed of
multiple processing layers to learn representations of data with multiple levels of abstraction”.
What is Deep Learning? It means using a neural network with several layers of nodes studying the
relationship between input and output (with some optimization on our dataset).
Why is it generally better than other ML methods on image, speech, and certain other types of data?
The series of layers between input and output compute relevant features (especially in hidden layers
that learn features characteristic of some local patterns in an image) automatically in a series of stages,
as our brains seem to.
Nowadays we have huge datasets that allow us to learn deep (with many, many, many layers) learning
networks, but we have also few that are powerful enough to train these models. The ImageNet project
is a large visual database designed for use in visual object recognition software research. More than
14 million images have been hand-annotated by the project to indicate what objects are pictured and
in at least one million of the images, bounding boxes are also provided. ImageNet contains more than
20.000 categories, with a typical category, such as "balloon" or "strawberry", consisting of several
hundred images. Since 2010, the ImageNet project runs an annual software contest, the ImageNet
Large Scale Visual Recognition Challenge (ILSVRC), where software programs compete to correctly
classify and detect objects and scenes. The challenge uses a "trimmed" list of one thousand non-
overlapping classes. In 2018 we had another revolution: Dueling (Generative Adversarial) Neural
Networks, whose concept is that we have two neural networks that compete enabling me to generate
new data (explanations on how it works better explained in GAN chapter). In 2019 there were an
evolution on smooth-talking AI assistants, like Alexa, Siri, and so on. In 2021 we had multi-skilled
AI, aiming to have approaches that are not operating on a single modality but on a bunch of modalities
altogether, like in robotics. In 2022 we are using for the first time AI for protein folding, planning to
use AI in medicine for drug discovery.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17

Anteprima parziale del testo

Scarica Deep Learning - Artificial Intelligence Systems e più Sbobinature in PDF di Machine learning solo su Docsity!

MACHINE LEARNING (mod. 2 )

1 - INTRODUCTION

Everything started in 1966 with The Summer Vision Project, an attempt in the reconstruction of a significant part of a visual system. We can see the timeline of the evolution of this field. At the beginning people started with analyzing two dimensional signals, and that the so-called Digital Image Processing. Later was developed the Optical Flow, that actually is a process for computing what is happening in a scene in terms of motions (of pixels). Going ahead, we can see the Kalman filters, basic technique to track blobs objects in a scene. All the techniques till 2004 were either filter-based or rule-based. In 200 2 started the so-called Learning, that represent a massive changing in this field, like machine learning fell in love with computer vision and a lot of things became possible. We can see some examples of improvement in this field, like the pedestrian detection (e.g., providing some good features with Histogram Of Oriented Gradient to Support Vector Machines), face detection (using Viola-Jones method for comparing local blocks in an image, and so on. Since 2012, we saw the transition from machine learning to deep learning in computer vision, because it was demonstrated that deep learning technique was stronger than machine learning. We can see the relationship between AI, ML and DL; artificial intelligence is the big discipline that has been invented first, whose idea was to create computers that simulate the human intelligence; then inside artificial intelligence you have several areas and machine learning is one of them and the difference between a general artificial intelligence technique is that the machine learning is a subset of technique where you have a training set and you want to discover regularities from this, and then you want to learn a model transferring what you have learned to another dataset (test set); with deep learning we are still restricting the space. There exist a lot of definitions this 3 fields, like the one given by John McCarty about AI who said that “the objective is to make programs that learn from their experience as effectively as humans do”, or the definition of ML by Arthur Samuel that “is the science of getting computers to act without being explicitly programmed”, or about DL’ fathers (Y. Bengio, G. Hinton, Y. LeCun) published a paper Nature giving its first definition: “DL allows computational models that are composed of multiple processing layers to learn representations of data with multiple levels of abstraction”. What is Deep Learning? It means using a neural network with several layers of nodes studying the relationship between input and output (with some optimization on our dataset). Why is it generally better than other ML methods on image, speech, and certain other types of data? The series of layers between input and output compute relevant features (especially in hidden layers that learn features characteristic of some local patterns in an image) automatically in a series of stages, as our brains seem to. Nowadays we have huge datasets that allow us to learn deep (with many, many, many layers) learning networks, but we have also few that are powerful enough to train these models. The ImageNet project is a large visual database designed for use in visual object recognition software research. More than 14 million images have been hand-annotated by the project to indicate what objects are pictured and in at least one million of the images, bounding boxes are also provided. ImageNet contains more than 20.000 categories, with a typical category, such as "balloon" or "strawberry", consisting of several hundred images. Since 2010, the ImageNet project runs an annual software contest, the ImageNet Large Scale Visual Recognition Challenge (ILSVRC), where software programs compete to correctly classify and detect objects and scenes. The challenge uses a "trimmed" list of one thousand non- overlapping classes. In 2018 we had another revolution: Dueling (Generative Adversarial) Neural Networks, whose concept is that we have two neural networks that compete enabling me to generate new data (explanations on how it works better explained in GAN chapter). In 2019 there were an evolution on smooth-talking AI assistants, like Alexa, Siri, and so on. In 2021 we had multi-skilled AI, aiming to have approaches that are not operating on a single modality but on a bunch of modalities altogether, like in robotics. In 2022 we are using for the first time AI for protein folding, planning to use AI in medicine for drug discovery.

2 - BRIEF HISTORY OF NEURAL NETWORKS

What's the structure of biological neuron? The structure of the biological neuron is roughly illustrated in the slide 3. There is the nucleus for the processing of our brain takes place, there are the dendrites that are the connection of neurons with others, there is the axon where the information computed in the nucleus moves away through the synapses that will connect to the dendrites. So, we have some branching input and branching output, and this is what is happening in artificial neural perceptron. There is a flow of information from the dendrites to the axon, and there is a cell body or soma where the processing takes place. We also have the same idea in the perceptron. In our brain, we have synapses that can be excitatory or inhibited. A perceptron is a nonlinear parameterized function with restricted output range. Perceptron is a first machine learning tool, it's actually a model that has some weights that are trained in order to, for instance, classify a dataset into classes. And the computation that is happening in the perceptron is shown clearly here. There are some input values of a vector x and then you add q weights that is associated to each input. So, we have an input and then you multiply it by his weight and then you sum all of those weighted inputs. There is also a fundamental component that is the h function because the results of this information should pass through a function that is called activation function, that initially was simply a threshold. The parameters are the data, the function is nonlinear because typically h is a nonlinear function and with restricted output range because originally the idea was to put the threshold, indeed the activation function that were used in neural network in the earliest implementation are called the traditional non-linear activation function, such as the sigmoid (range: 0 ,1) and hyperbolic tangent (range: - 1 ,1). When we combine the multiple perceptron in our neural network and when we use this kind of function, the researcher realized that this function may have problems because when we compute the derivative, the order of these two tend to be zero. So, they invented the more sophisticated, indeed in general with feedforward and convolutional neural network, we prefer this kind of modern activation functions: ReLU (most popular, used inside AlexNet) and Leaky ReLU. We can also see that the branches of the perceptron correspond to the three components of biological neuron (dendrite - > input, soma - > place where the computation takes place, axon - > output branch). Let's see the details of the story. At the beginning, there was an idea from McCulloch and Pitts that was to build an electronic brain, very small; it takes a vector as input and generate only a binary output whose weights are fixed. Then, there is the real perceptron, that is not just a computational model to implement the function, but it's one of the simplest machine learning tools [see the algorithm and the graphical representation of how it works]. The perceptron learning rule can be only used if you have something that is one layer because you need the direct access to the output. Moreover, this object cannot be used for nonlinear problems, but what you can do smart is to combine the perceptron in a structure that is made up of different layers. One note is that we cannot use the same activation function for the Hidden unit and the Output unit because they have a different role in the network. But the researchers understood that it cannot be used for a simple nonlinear problem. Let me try to show you a problem of XOR that they could not be solved with the perceptron: if you add up the blue points and the white points in that way, there is no line that can separate them. So, you can either specify which are good values of the weights or you can learn them, but XOR is not - > they needed something a bit more sophisticated. This problem generated the First AI Winter, a decade where the researchers think for clever strategies to train this model because neural models cannot be applied to complex tasks. This is the moment where multilayer perceptron and backpropagation were invented. They went out from this problem by with a very simple idea. We can think about composing multiple neurons in multiple layers and we have something very flexible. Each edge in this graph corresponds to a weight, and inside these cells we can choose the activation function, typically the same one for all the layers. The Multi-Layer Perceptron is based on the idea of densely connecting different artificial neurons realizing composition of nonlinear function. We are not limited by the number of output that you can put in this architecture. An example of an architecture that can be used for this sense to do one task in computer vision is semantic segmentation: we take an image and we output the segmentation map, also an image of the same resolution of the input image, and we assign discrete values to each pixel in the input. Another important aspect is the direction for the information flow. This is the peculiar aspect of a subset of neural networks that are called feedforward neural networks; they implement the Directed Acyclic Graph (DAG). The combination of the multiple perceptron is something that was not simple. A solution is the backpropagation (1986); this algorithm is a recursive procedure and that is very efficient that look to train on relatively large dataset: you have your weights and your bias pre initialized for all the neurons in your multilayer perceptron; then you take one sample for your training set or a small set of samples, you pass it through the network, you compute the prediction given the current input and given the current set of weights and you compare this prediction with the output that is the true label (to compare means we need to do this mathematically, so we need a function that measure how much my prediction differs from my label); once we have measured these error signal, we can use it to go back and update the weights in the so-called backpropagation. In practice, for neural network the concept of learning means the concepts of solving the optimization problem. The way we solve the optimization problem is through stochastic gradient descent and you want to adjust the weights of the

3 - MACHINE LEARNING RECAP

What is Machine Learning? It’s a branch of AI, concerned with the design and development

of algorithms that allow computers to acquire knowledge based on empirical data. The main

difference between the AI and the machine learning is the fact that the idea of ML is prior

knowledge to learn a model.

The reason why machine learning became so popular is because it can be used in several cases

of problem. Th ML approach is very different wrt computer science one because in the latter

we use data and a program for obtaining some results, while in ML we use data that produce

some results in order to obtain a model/program that is able to perform some tasks.

When do we apply ML techniques? When we want to recognize patterns, so we want to

recognize from images the number that is containing, we want to recognize from the image of

the face, we want to assign a label to each pixel on that image. When we want to perform a

prediction on time, for example the prediction of future stock prices over time. When we want

to generate patterns that means that we need a model to learn an underlying distribution. When

we want to recognize anomalies. When we want to make a prediction in the best move in the

games (reinforcement learning).

A definition of ML: “A computer program is said to learn from experience E wrt some class

of tasks T and performance measure P; if its performance at task in T, as measured by P,

improves with experience E” (Tom Mitchell).

We will treat deep learning models that are able to solve the three families, so we will discuss

neural networks that operate with supervised, unsupervised (GAN) and reinforcement

learning.

Supervised learning: we are given the data and the desired output, they are finding for the

label, learning a model (for example, in object detection). Here, we talk about classification

and regression, in which we have vectors or images or whatever, we have only one

output/prediction that can be the label. It is still supervised learning when we can use the hybrid

neural network, for instance, made of CNN path and the RNN path.

Unsupervised learning: we are only given the data with no annotation, and we want to extract

some regularities out of our data.

Semi-supervised learning: it’s a hybrid among the two above, so given the training data, we

have only a few desired outputs. It means that you are only given your data that typically are

vectors and then you have some algorithm, some groups of data that have similar features,

called clustering (for example, in genomics, in social network analysis, in dimensionality

reduction). Even deep neural network can be used for clustering and not only traditional

shallow models.

Reinforcement learning: we have these interaction loop that allows our agents to learn patterns.

We have this learning in which the agent is trying some actions in some spaces and the

environment is giving back some information about the state (if the action is being good or

not) and also giving back some rewards; thanks to this loop, the learning take place.

What about designing a Learning System? Every time that we want to design the learning

system, we will first need to focus on which data are going to feed my system, and also then

we have to decide a function that, for instance, maps my data from input space to the output

space. This function is typically the model, and I have to choose the model and the algorithm.

Once I have chosen the function, I need to choose the representation of the function and the

learning algorithm is directly related to this choice. Also, I need to have an objective criterion

to tell me if my algorithm is doing well, if my function correctly approximates my ground

truth/label. And then I need some evaluation metrics.

Describing the different machine learning algorithms, we can say that for all of them, we have

different components in terms of functional representation, in terms of optimization, and in

terms of evaluation. In Supervised learning settings, we may have different choices for

functional representation: the simplest algorithm for classification model is K-Nearest

Neighbors (non-parametric model); another possible choice is to use Neural Networks

(numerical function) and Support Vector Machines (numerical function); another family is

parametric models, that have a probabilistic interpretation, like Naïve Bayes; and then there is

another family, symbolic functions, where you learn a function representation indirectly, like

the decision trees; the last family is aggregation, where a functional representation is a

combination of simple functions, which main idea is ensemble models, like bagging, Adaboost

and random forest. Also, about unsupervised learning we have some more function

representations, for example, the clustering family like K-means and Gaussian mixture model,

or dimensionality reduction family where you learn the transformation, like the PCA.

Which is the difference between discriminative and generative models? Discriminative models

are focused on the decision boundary mapping directly x to y, while generative models are

based on the probabilistic/statistic distribution of the data.

The design of the optimization algorithm is the core to many machine learning algorithms.

Initially, we randomly initialize the weights of our model and then we are going to use some

iterative techniques to learn the optimal parameters. Regarding the possible search and

optimization algorithms, we have seen one famous that is the gradient descent. The choice of

the optimization algorithm is very important as the design of the target function and of the

error measure/metric of evaluation.

Even the generalization, the ability to perform well on previously unobserved inputs on our

data, is very important and we are interested in minimizing the generalization error. In machine

learning, typically we talk about minimizing the risk/expected loss and also the empirical loss

in order to measure the discrepancy between the ground truth and the predicted value given

some weights and some improvements. About the Empirical Risk Minimization, if the training

set is a representative of an unknown distribution, the empirical loss is a proxy for the risk.

The factors determining how well a machine learning algorithm will perform are its ability to

make either the training error small or the gap between training and test error small. These two

factors correspond to the cases of underfitting and overfitting. Underfitting occurs when the

model is not able to obtain a sufficiently low error value on the training set. Overfitting occurs

when the gap between the training error and test error is too large. What we are aiming to is

that we want to control both in order to not having low or high model capacity. About the No

Free Lunch theorem, we have problems, we have data, and we don't know which is the best

model/machine learning algorithm that can be used for a certain problem. In any case, we will

have models that are simplification of the reality, in most of the cases we will have assumptions

(model bias), so this will create some model bias, and of course the assumption may be

extremely good in some cases or really bad in others.

One thing that we always do is that in our optimization problem, we not only use the objective

function that is the sum of the individual losses, but we also use the regularization. We need

to choose the optimal l parameter such that we don’t underfit (l is very high) or overfit (l

tends to 0) the model. Look to the processes of ML in practice.

the neural network/deep learning/ feedforward network does, that is to learn the mapping j from the data, in which we start with low-level, then medium level and finally high-level features. It makes sense to conclude our discussion on feedforward network with an example of XOR problem. We have seen that with a linear model we aren’t able to represent XOR in a correct way, because the set of equations are not consistent. So, the idea to solve it, is learning a different feature space: one possible solution will be to define a feedforward network with one more layer (1 input layer + 1 hidden layer + 1 output layer) that is parametrized by a function f(1)^ that takes in input the variables x, the weights W and the bias c, and his output is parametrized by the function f(2), so the complete model will be f(2)(f(1)(x)). In this way, we have demonstrated that for a certain choice of the parameters and for our functions f(1)^ and f(2), we can correctly classify every example in the set. For a more complicated function this is not true, but what we typically need to do is to use the gradient. What we would like to see is how to train our feedforward neural network in order to learn our function as parameterized by the parameter feedback such that we have to approximate as much as possible the unknown function f* for representing our ideal classifier. Before entering into their propagation, we need to do several choices in the design of the feedforward network. In particular, two aspects that we need to decide are: the cost function and the output layers. Then another important design choice is the different optimization functions that we have inside the deep network. Regarding the choice of the Cost Function, we know that it should measure the discrepancy between the prediction of the neural network and our target output. We have an infinity (in the sense that we can always invent it according to our need/problem) number of cost functions we can specify. The choice of the cost function is not independent on the choice of the output units. We can see the most popular ones used for classification and regression problems. Ideas for classification loss are to use the maximum likelihood for finding the optimal q, or we can use as a divergence the binary cross-entropy between the training data and the model’s predictions, or the categorical cross-entropy. About regression, we know the simplest losses of mean square error (MSE) and of mean absolute error (MAE), but another possibility is to use the Huber that is a combination of the two above. One possibility for the Output Units is to have Linear Units where the y output is given by a linear combination of weights W by the inputs h plus the bias b; it can happen that the gradient of the output of the model is close to 0 and it is problematic. Another possibility for output units are the Softmax Units that expresses some form of normalization in the probabilities expressed by the formula softmax(z)i in the slide, but it is better to consider the logarithm of that function to simplify it. We tend to use it because maximizing log-likelihood encourages zi to be pushed up, while encouraging all z to be pushed down (softmax encourages competition among the best classes). Another important concept is the architectural choice of Hidden Units, whose design is an active area of research. What is happening inside the hidden unit is that we are accepting an input, then we are going to find the transformation and then we are applying some elementwise non-linear function, finally we obtain the output. Nowadays the most popular activation function is the Rectified Linear Units, basically we are given an input z and we are taking the maximum between 0 and z and this represent the output of the activation function. It is similar to linear units that are easy to optimize, and in particular, what is happening is that the gradient is either 0 or 1. One bad thing about it is that these hidden units are not everywhere differentiable, moreover the “die” i.e. when inactive they will never update. To improve overall value over the years, the researcher have proposed different variations in particular to the formula on the top, that indicates what is called Generalized Rectified Linear Unit, in which we add ai min{0, zi} according to some values of aI listed in the slide with their graphical representations. Other activation functions are: Exponential Linear Units, which takes all the benefits of ReLU and doesn’t get killed; Maxout Units, that generalizes the ReLU but doesn’t fit into the mold and makes a piecewise linear approximation to an arbitrary convex function; more traditional for hidden units are the Sigmoid Units, which push outputs to range [0,1], and a good thing is that it can be differentiable, but the bad thing is that it saturates most of the domain and it is very sensitive when s(z) is closer to 0; an improvement of the sigmoid problems is given by the formula of Tanh Units. For concluding this part, we add that in most of the implementations of feedforward and convolutional neural network, sigmoid are not used, rather commonly use tanh; moreover, use ReLU by default, but be careful with learning rates, and try other generalized ReLUs and Maxout for possible improvements [give a look to the table summary]. The last part of this class is about a Universality Approximation Theorem. We are now discussing the choice related to the architecture, so the specific number of layers. This is actually a largely unsolved problem. In particular, there are two factors that the influence the design of it for feedforward neural network: the depth and the width of the network and how many layers we need in order to learn our function. This problem is related to the problem of the expressivity of neural network. The most famous result is the theoretical results by Cybenko, called the Universality Approximation Theorem. It was originally started for the additional activation function such as the sigmoid but then the prosecution theory also being studied and expanded in the case of a much wider class of activation function. The problem is that we are not guaranteed that our training algorithm will be able to learn that function. So, we have practical issues and problem related to the optimization and to the overfitting.

5 - BACKPROPAGATION

One of the things of the advancement of the progressive neural network was the backpropagation. We have

designed/chosen our optimal neural network and we want to learn it; this is where backpropagation comes

into game. The perceptron learning rule is the first algorithm that allows you to train the neural network.

However, this is a very specialized technique that cannot be extended for the multilayer perceptron because

of the weights of the last layer. So, we’re learning the weights of our neural network through the combination

of gradient descent, in particular, stochastic random descent. The backpropagation is an iterative procedure

for computing gradients. The gradient is the vector of partial derivatives wrt to all the coordinates of the

weights which measure how fast the loss changes in one direction (when the gradient is 0, it doesn’t change

in any direction). Once we are able to compute the gradient, we apply the procedure so-called batch gradient

descent: we start initializing the parameter q and, in this case, also the learning rate ek, and we define a stopping

criterion; so, we take all our samples in the training set, and we compute the gradient for each individual

sample and then we use the gradient learning rule for updating the weights q. There are two relevant things

happening into the loop: one is the computation of the gradient, and the other is the application of the update

rule. We are using all the samples because we have to do this for all the weights of the neural network. So, if

the neural net is larger, we need to be able to apply this update through for all, so we need to compute the

relevant gradient for all the weights, and this is very painful. We are going to discuss gradient computation =

backpropagation.

We can see graphically some results that we can obtain applying the gradient descent in one direction. In

neural network, especially in very complex NN, the optimization problem is non-convex and probably has

local minima; this issue avoided the people to use the neural network for a long time because they preferred

to use methods for finding optimal solutions, this is the reason they used more kernel methods that were always

guaranteed to find the global optimum, a good solution. When we use very large dimensional spaces, the

saddle points, which represent some directions curve upwards and downwards, are very common and also

them are another problem.

[Video of G. Hinton which explains the inspiration behind the backpropagation]. We are interested in the

errors, we are interested in computing these derivatives wrt the hidden activities, because through that we can

compute the error derivatives wrt the weights. A neural network is made of neurons densely interconnected,

so we need to combine the effect of each error on such neuron that should propagate to all the neurons that

are connected to it.

How do we learn the weights? There exist 3 ideas: randomly perturb one weight, see if it improves

performance and save the change, resembling evolutionary computations, but it’s very inefficient because

needs to do many passes over a sample set for just one weight change and it’s hard in the final part of the

learning; perturb all the weights in parallel, and correlate the performance gain with weight changes, but it is

also inefficient and very hard to implement and does not work; only perturb activations since they are fewer,

and also this is very inefficient.

Backpropagation is an algorithm that is made of 3 steps:

1 - Feedforward Propagation: once we have some inputs x that correspond to the data point and given some

weights, we will obtain the output that can be a single prediction or multiple predictions.

2 - Error Evaluation: we compare the prediction/predicted output with ground truth labels to get the error

signal, computing a scalar cost depending on the loss function.

3 - Backward Pass: we take this error signal, and we propagate back to get derivatives for learning, so it allows

information to flow backwards from cost to compute the gradient.

From the training data we don’t know what the hidden units should do, but we can compute how fast the error

changes as we change a hidden activity. Use error derivatives wrt hidden activities, each hidden unit can affect

many output units and have separate effects on error. We combine these effects, and we can compute error

derivatives for hidden units efficiently. Once we have error derivatives for hidden activities, easy to get error

derivatives for weights going in. Logistic (aka Soft step) and Tanh are good thing of the traditional activation

function that we are going to use.

[Look the formulas, understand better with the example in the following slides, and look the recap!]

7 - REGULARIZATION

Even if we have the best version of the gradient, the optimizer probably will not suffice to have a good performance on our test. And the reason is that with deep neural network, we have model with very high capacity for which overfitting is a serious problem. Regularization is one of the most central topics in machine learning and therefore also in deep learning; it allows neural networks to have better performances in a large variety of tasks and also avoids the critical issue of overfitting. We’ll see different regularization strategies, but we’ll focus mostly on the Lp^ methods. Our central challenge in machine learning is that our models are able to generalize, in the sense they should perform well on new previously unseen inputs, called generalization. We assume that our training and test data are drawn as i.i.d (independent and identically distributed) from the same unknown distribution. We can control the tradeoff between the situation of underfitting and overfitting by altering the model capacity of the neural networks, which means by changing the number of parameters/weights inside the neural network; we don’t like to have a model with high capacity because then we will risk getting the overfitting zone, and on the other hand with model with low capacity we don’t have the chance to learn well on the training data. So, we likely need to stay in that region where we have the optimal capacity. About the strategies to avoid the overfitting therefore also include the changing of the capacity of the model; other two approaches are: using more data, probably it’s the best choice because the more data we have, the less the model falls down in overfitting problem; averaging many different models, that can be obtained by considering different models or by taking the same model being trained on different subsets of training data. Regularization is any modification we make to a learning algorithm that is intended to reduce its generalization error but not its training error. We are interested into regularization methods for deep architectures because deep learning algorithms are typically applied to complicated domains (e.g., images, sequences, audio, etc), also because controlling the complexity of the model is complex and a very challenging task; instead, in practical applications we almost always find that the best model (the one that minimize the generalization error) is a large model that has been regularized appropriately. Overfitting in neural networks can be controlled in many different ways: Architecture (limiting the number of hidden layers or units per layer), Early Stopping (starting with small weights and stopping before the overfitting takes place), Weight-Decay (penalizing large weights using constraints on their squared values - L2 penalty- or absolute values - L1 penalty), and Noise. The most traditional approach is to limit the capacity of the model by adding a penalty to the objective function, given by W(q) and l is a hyperparameter that goes from 0 to infinity that is a tradeoff between these two functions. The most useful approach that satisfy this scheme of using this penalty parameter is L2 Regularization where we have only the weights associated to a certain layer and then we are taking the sum of the squared norm of the weights. Another option is using L1 Regularization, that is implemented similarly to the previous method but with the only difference that we are taking the one norm of the weights; in this case, the more l is bigger, the more weights become 0. This method is mostly used as a feature selection mechanism, for instance LASSO (Least Absolute Shrinkage and Selection Operator) which integrates an L1 penalty together with a linear model and least squares cost function. The L1 penalty causes a subset of the weights to become zero, suggesting that those features can be discarded. Data Augmentation is based on the idea of using more data for generalizing better a ML model; however, the amount of data is limited, so we have to create synthesized data. This approach is widely used for classification and image recognition, whose idea is to generate new samples (x, y) just by transforming inputs. This method cannot necessarily be applied to other problems, for instance with the density estimation problem. Another problem is applying transformation that would change the class (‘b’ vs ‘d’ and ‘6’ vs ‘9’). Another strategy for regularization is the addition of random Noise to the input of the network, like in the example of Gaussian noise in which the output is the original output plus the noise that is amplified in proportion to the weights of the layers in the networks. Another technique for the regularization is Early Stopping: we start with small weights and stop the learning before it overfits or the gap between the validation set loss and training set loss starts to increase; every time the error on the validation set improves, we store a copy of the model parameters, and then when the training terminates, we return these parameters rather than the latest parameters. Another approach is the Multi-Task Learning for improving the generalization by pooling the examples, like soft constraints on the parameters, out of several tasks. We can see in the slide an example of a common way of analyzing multi-task learning by having both generic parameters (typically the upper layers of the NN) shared across all the tasks and task-specific parameters (typically the lower layers of the NN) for better controlling the overfitting. Another approach is called Parameter Sharing, in which, instead of enforcing same parameters, we can enforce soft constraints such that certain parameters inside the network are close to another one in order to store in memory only a subset of parameters. One architecture that use this idea is convolutional neural network applied in computer vision, which takes this property into account by sharing parameters across multiple image locations [look better from slides how it works]. Another approach to avoid overfitting is to use Model Ensembles, whose idea is to have different models that are being trained separately, then we have each model that produce an output and then we combine the prediction of the multi models in order to have better performance; the simplest approach is to create a different model from the original dataset obtaining a slightly different version of the dataset. Last one approach is Dropout in which we are taking a traditional feedforward neural network and then we randomly set some neurons to 0 in the forward pass, whose choice is determined by a probability r; it works because it forces the network to have a redundant representation. Bagging is a method of averaging over several models to improve generalization, but it is impractical to train many neural networks since it is expensive in time and memory, while dropout makes it practical to apply bagging to very many large neural networks. Basically, when we train the neural networks with dropout we use minibatch.

8 - CONVOLUTIONAL NEURAL NETWORKS

The reason why CNN became so popular is because its application benefits of structured data. About differences between traditional ML approaches and DL ones is that in the first we train the classifier and then we apply the trained classifier, while in the latter we are just going to apply the trained classifier. In CV, we have seen that there exists some features that are more effective than others. When we work with deep networks, the situation is different because the boundary between the feature structure and the classifier is actually very fancy because we have a bunch of layers that are jointly trained (main difference with ML approach). Convolutional Neural Network is simply feedforward neural networks that use a convolutional rather than a general matrix multiplication in at least one of their layers. Given an input and given the fact that we are defining a kernel, a small matrix with some values, then the result of the convolutional is another matrix and its elements are computed by considering all the associated elements of the input matrix and the kernel, multiplying them, and then summing up. For filling the elements in the new matrix, we move the kernel and repeat the same operation. This operation can be formalized by the formula below the slide, in which we have the input matrix and a smaller kernel matrix, then we iterate over indexes m and n and we are going to have an output, another matrix which each element is filled according to this equation. The first important study on the visual cortex was done by Hubel and Wiesel in 1962, which figured out that in our brain we have some parts where we process the visual information that operate by discovering some form of local features. So, the brain is structured in different sections, each with a specific task, to recognize objects and create a body reaction; in the first layers we detect some information at the local scale, while in the last layers we are going to discover more complex shapes. The idea of convolutional neural network is somehow to have a computational approach that emulates these mechanisms. The Neocognitron is the first computation in order to try to emulate it and it is actually made up of two level of cells that instruct the local features, the S-cells that extract local features and the C-cells that aggregate what is below allowing for positional errors. LeNet is the first approach really used in the real problem in an application domain with CNN invented in 1998. Given the input, we apply the convolutional layers for computing the set of feature maps with a certain kernel, and then when we apply the subsampling layers in order to reduce the size of this feature; then we repeat the same operation, we have a convolution, for having a certain number of feature maps and then we subsample again until we reach more resolution for our feature map such that we can take all of them and process them with traditional fully connected layers; the output layer of our neural network, in this case, is made of ten different output corresponding to the digits since the basic problem was a digital revolution. The Convolution is, in general, an operation of two function of real-valued argument. We can think as a convolution the example of one dimension in the theory of signals, which involves the input and the kernel and, instead of computing, there is a match since we are in the continuous space; so, we are computing the output that is a signal, still a function. It's more common in digital signal processing to use discrete signals instead of continuous signals; in that discrete space, instead of taking the integral, we are taking the summation of the argument that is actually the same of continuous space. In the case of 2D convolutions, convolution is a general-purpose filtering operation for images, in which we apply a kernel matrix, and it works by determining the value of a central pixel by adding the weighted values of all its neighbors together; the output will be a new modified filtered image [short clip of how it works]. In the two-dimensional case of the kernel operation on a small window is exactly the same. The value of the parameters are the same in the sense the value of the same-colored edges are the same. This leads us to repeat the two fundamental property of CNN: the local connectivity, so neurons are connected all only to a small number of neurons in the previous layer; and the sharing weight parameters across the spatial position, that leads us to reduce the number of parameters such that our neural network is much more robust to overfitting. In the earliest implementation of a convolutional neural network nowadays things have changed a little bit because there are basically three distinct types of operation inside the CNN: we can apply either the convolution, or some form of non-linearity, or some form of pooling. In practice, the convolutional layer consists of a set of filters and each filter covers a small portion of the input data, so-called receptive field, producing a multi-dimensional feature map. About the CNN architecture, we can see that given an input, for instance an image, our neural network will proceed with a convolutional stage, then a non-linear stage where we apply some non-linear activation function and then another non-linear stage that is the subsampling stage whose receive an output that will be reduced to a certain dimension; this operation is repeated multiple times until the end. When we apply the convolution, we are taking the input and the shared weights and computing the formula in the slide that will pass through the activation [practical example of how it works]. Sometimes, we want the output of a convolution to have the same dimension of the input matrix; in this case, the solution is zero padding that means appending zeros outside the main matrix of the input. Once we have the output of this operation, we apply the non-linearity that we have already seen in a previous chapter, for example the ReLU function. After we have passed the convolution and non- linearity layers, we want to downsample the tensor and it can be done in many ways, for instance we can operate with max pooling which takes subsets of each matrix in that sensor and then computes the maximum of a block region. In

9 - CNN APPLICATIONS

Last thing to discuss about CNN is their flexibility to be applied not only to categorization problem. So far we have seen in the Digit classification with 10 classes for dataset MNIST using LeNet and the Object recognition for dataset ImageNet with 1000 possible classes using AlexNet. We need a neural network that does not necessarily deal with classification problem but is also able to deal with the structure of the prediction problem, and among the structural prediction problems that are of interest in computer vision, two of them are object detection and object segmentation. In the case of object detection, we would like that the neural network predicts at the same time multiple bounding boxes and each bounding boxes is associated with a category, while about segmentation it needs image as input and image as output because we want to assign the pixel of one color to a possible label. [Not in this slide: in computer vision we have also semantic segmentation and instance segmentation; semantic segmentation means the pixel of the class darker will be always of the same class, while for instance segmentation we have different labels for different objects.] How convolutional neural network were adapted in particular to detection and segmentation? Let's see first the Object Detection. It means that we have to simultaneously solve classification and regression problem because the input is the image, but the output are the different bounding boxes + the labels associated to each object in the image. For each object in the image, since the task is very difficult, is also more difficult to find the dataset of very large scale. So, the reasons why we use CNNs for detection is data scarcity and then every time we are applying the convolutional layer, we are achieving some feature representation preserving the information about the essence of the object. In the community it’s available for the detection the PASCAL VOC dataset where the number of categories and the number of images are quite limited wrt large dataset the community have at their disposal nowadays. Something very stronger came from Amsterdam group with the Selective Search that was also used in the very first deep network for object detection. It is an unsupervised technique which clusters the pixels of the image at different resolution using bottom-up grouping of image regions to generate a hierarchy of small to large regions; its goal is being fast to detect objects at any scale using hierarchical algorithms by consider multiple grouping criteria. So, the first step is to take the input and to generate a sub- segmentation creating a huge amount of possible candidates; then we recursively combine similar regions into larger ones; and, finally, it allows us to have bounding boxes that contain possible objects at different locations in the image. Let’s introduce also the R-CNN from Berkeley, that’s the very first work of applying a CNN for object detection; its idea is to use selective search to extract a certain number of proposals (2000), then each proposal is scaled to the resolution that the AlexNet wants, and then we compute the CNN features learning a classifier. They also proposed something slightly more sophisticated than that by using bounding box regression [look the following slides for more details, and also the results on PASCAL VOC and ImageNet datasets]. Which were the issues with R-CNN why the wider community decided to move over and to progress? First issue is that this is not a model where we have a real training because we have a multi-stage procedure, and the second point is that each object proposal is processed separately. Another problem is regarding the testing that is computationally slow, so it takes a huge amount of time to train the network as we would classify about 2000 region proposal per image and it last around 47 second for each test image. The first attempt to overcome this issues were Fast R-CNN in which we are using RoI (Region of Interest) Pooling that shares the forward pass of a CNN for an image across its selected subregions and then it combines all models into one network. The difficulty that the bounding boxes have different dimensions, so also the associated feature maps will have different dimensions, can be solved using the RoI Pooling for layer regions that are reshaped into a fixed size for being fed into a fully connected layer. We can also see the function loss for our neural network that represents a tradeoff between the two losses, one serving classification and the other one for regression. The fact that we are using to share the features extracted enables this algorithm to be much faster than R-CNN about the training and the test time. We have seen both R-CNN and Fast R-CNN use selective search algorithm that is a slow and time-consuming process; so, the biggest advance in the community was given by Ren’s group with Faster R-CNN which eliminated the selective search letting the network to learn the region proposal. Later, was introduced another method, so-called You Only Look Once (YOLO) different from previous methods which used regions to localize objects within the image, but it treats the detection as a regression problem using single convolutional network to predict the bounding boxes and the class probabilities for these boxes. It works by taking an input and dividing it in certain grids, then to have a network that produce two things as output, one for bounding boxes with the associated confidence and the other one for some class probability maps, and finally we obtain the final detections. It was very interesting for the community because it was much much faster than the previous methods, but it was also a limitation of struggling with small objects within the image. Instance Segmentation is a field in which the boundary between detection and segmentation is very close, in which the goal is to assign a label to each pixel of the image. One very popular approach is Mask R-CNN, an extension of the Faster R-CNN, which has an additional branch for predicting segmentation masks on each RoI. In this case, the image is processed by the CNN to extract some features and to generate the feature maps, then Region Proposal Network (RPN) uses a CNN to generate the multiple Region of Interest, and RoI Align network outputs multiple bounding boxes rather than a single definite one and warp them into a fixed dimension. Warped features are then fed into fully connected layers to make classification using softmax and boundary box prediction is further refined using the regression model; warped features are also fed into two CNNs to output a binary mask for each RoI. Mask classifier allows the network to generate masks for every class without competition among classes. We can see also different applications about Semantic Segmentation which is a problem where we need to assign a label to each pixel of the image. An example is that there exists a family of the so-called Pixel-level Prediction task as we can see in the slide. Two important fields where we need semantic segmentation are for sure Autonomous Driving and Medical Imaging. It is based on the idea of reinterpreting classification network as Fully Convolutional in which we operate on each pixel separately, instead of having a fully connected layer after the convolutional structure. Other researchers decided to operate by introducing Upsampling Layers.

10 - RECURRENT NEURAL NETWORKS

We want to have some deep neural networks for the purpose of having some input that haven’t a fixed

length, such that the correlation between the neighboring words or the neighboring characters should be

taken into account by the model when it does the prediction.

Why do we need the neural network that processes data of variable-length sequence? We can see three

different examples: Document Classification, so given the text of words and each document has different

number of words, but we still want to assign a label to the documents, to know if it is talking, for example,

about technology, medical domains, sports, and so on; Sentiment Analysis, for classifying a product, a

restaurant or movie as positive, neutral or negative; and Image Captioning for producing some sentences

that describes the input image contents.

So far, for regular feedforward networks and convolutional neural networks we had a fixed size

single2single and we had only one label as prediction, while for Recurrent neural networks we have

multiple2single (for Sentiment Analysis) or single2multiple (for Image Captioning). Moreover, we also

have problems where we have multiple inputs and multiple output (multiple2multiple or

sequence2sequence), for example to translate a sentence from English to French, or to predict video

frames; the difference among the two previous examples is that for Machine Translation before we have

only inputs and then outputs while for Video Frame Prediction we have inputs and outputs simultaneously.

What is a Recurrent Neural Network (RNN)? It is a class of artificial neural networks where connections

between nodes can create a cycle, allowing output from some nodes to affect subsequent input to the same

nodes, allowing it to exhibit temporal dynamic behavior. Derived from feedforward neural networks,

RNNs can use their internal state (memory) to process variable length sequences of inputs, and this neural

network learn some representations denoted with h that eventually will be used whenever to perform a

prediction, in this case, associated to one input x. Referring to the cycle, we can see the formula of

recurrence such that each state ht depends on the hidden representation at the preview state ht- 1 and the

input at the current state xt. If we unroll the single representation of RNN, we obtain the architecture in

the slide that implicitly use to perform the backpropagation.

Both the representations are equivalent, in particular the so-called recurrent graph is a bit more common,

but the unfolded graph gives already an intuition on how we can train such a model. The recurrent neural

network were heavily inspired by the researchers in idea of control theory because the recurrence equation

resembles the update of the state that we have in dynamic systems.

An example is a current model that allows us to predict the next character, for instance, in this case, we

want the system to learn/predict the words ‘right’ given some context and information coming from the

previous characters.

How do we can implement it? Nothing surprisingly too much different actually; first we need to decide

to provide an input adopting some form of encoding where you have 1 in the position associated to the

character and 0 in all the other positions; then, we have a first set of weights that connect the input to the

hidden layer and also enters another weight from the previous representation of the state, and then another

more set of weight until the output layer that can be implemented as a linear transformation + softmax

function. It is reported an example with some of the results when they were training such a simple model

and, despite the model is really simple, after 2000 iterations they were able to produce something

meaningful in terms of words.

Let’s see the models of RNN. At the beginning, we can think to a Vanilla RNN Cell, which receives the

input x and the previous representation of the state ht- 1 ; in the inner part it is implemented the tanh function

as recurrence function for computing the new representation of the state ht. The problem of the tangent is

that if we compute the derivative part of the graph will be towards 0, a very small number; also for RNN

it is a serious problem because as we told in the hidden layer will enter two kinds of weight (one from the

input, one from the previous representation of the state) and their combination goes into the non-linearity.

In order to train such an object, it's quite convenient to consider RNN Unfolded for the representation of

the neural network, and we can think about something like the one we see in the slide in which the output

from a hidden layer is also the input for the next step - this means that some part of the parameters are

shared among the hidden of the network - and it is computed using tanh function, while the output at each

step by using softmax function.

11 - GENERATIVE ADVERSARIAL NETWORKS

We start discussing about Unsupervised Learning and the deep Generative Models that involves 3 models, whose

most important are the so-called Generative Adversarial Networks and Variational AutoEncoders.

[Give a glance to slides about Supervised and Unsupervised Learning]. One common taxonomy when we talk

about unsupervised learning is the one by Marc Aurelio Ranzato in which we have two categories of approaches:

Non-Probabilistic Models and Probabilistic Generative Models, that can be subdivided again in other two possible

approaches: explicit density and implicit density (smarter strategy).

In the task that we want to address with probabilistic generative models, we have all the disposal training data, but

we want to be able to generate new samples from the same distribution [search on Google: StyleGAN]. This is a

density estimation problem, so given the training data that are samples from the unknown distribution pdata(x) and

then we want to learn a similar probability distribution pmodel(x). So, we have two strategies to do that: explicit

density estimation really solve this problem, figuring out the optimization approaches such that if we parameterize

pmodel in some way, these parameters are learned such that they get close to pdata(x); implicit density estimation that

learn a model that can sample from pmodel(x) without explicitly defining it.

If we continue the taxonomy and we have the granularity representation of Generative Models, we can see for

implicit density the Direct methods (GAN), that are discussed in this chapter, and the Markov Chain models (GSN),

while for explicit density model we can see the Tractable density (PixelRNN/CNN discussed in next chapters) and

the Approximate density that can be divided in the Variational methods (VAE discussed in next chapters) and

Markov Chain methods (Boltzmann Machine). Before looking the details of the GAN, we have to understand why

we need the Generative Models; because they allow to create realistic samples for artwork, super-resolution,

colorization, and so on, they also can be used for simulation and planning and, finally, training generative models

can also enable inference of latent representations that can be useful as general features.

The Generative Adversarial Networks (GAN) don't consider any explicit density function, so they do not use the

procedure of explicitly learning the probability distribution, but they want to preserve the ability of sampling

something meaningful, and they also want to sample from a complex high-dimensional training distribution. The

main idea is to sample from a simple distribution and to learn transformation for training distribution with neural

network, for doing that there exists two kinds of networks: the input, for instance a random noise, is passed into a

network called Generator Network that has the role to translate what we are sampling in the simple space into

something complex; then, we obtain an output that is a sample from the training distribution and it is passed to the

Discriminator Network, which compares the real images (from training set) and fake images (from Generator

Network) and tells us which image is processing.

[Important question for the exam: the objective function of how we train the GAN]. We need to learn the optimal

parameters of the generator (minqg) and of the discriminator (maxqd), and we have two expectations: one is referred

to the discriminator output for real data x, so we want to maximize the objective such that Dd(x) is close to 1 (real)

and Dd(Gg(z)) is close to 0 (fake); the other one is referred to the discriminator output for generated fake data G(z),

so we want to minimize objective such that Dd(Gg(z)) is close to 1 (discriminator is fooled into thinking generated

G(z) is real).

In a paper of 2014, this objective function is represented as an alternation between the gradient ascent on

discriminator and gradient descent on generator, but this introduced some optimization difficulties because there

is always a matter of if the gradient is a strong signal or not, so this idea doesn’t work well; for this reason, they

proposed a very simple modification of this formula where they still optimize the objective function, but instead

of minimizing likelihood of discriminator being correct, now they maximize likelihood of discriminator being

wrong. But jointly training two networks is challenging and it can be unstable.

The alpha of the research community that started to study the GANs dedicated to have more stable learning

procedures.

[Another question for exam:] while we train all of these, how do we use it at this time? At this time, the

discriminator is not needed anymore, but it is an extra network that we use to make the generator be able to produce

very high quality, realistic images; so at this time, we can sample from my simple distribution of choice and then

only use the generator to produce the image, for instance, of a face that looks like the face is set in my training set.

Not only optimization matters, also the design of the network, as we may imagine, the design of the generator and

the discriminator matters a lot to produce something that is good quality; so, another branch of research focused

on this, which have the best architecture.

Now we are entering into the so-called GAN zoo, that is enabling us to generate very, very high-quality 3D things.

A very famous work is this by Chintala’s group in 2016, in which some people start to think which could be the

best architecture that they can design in order to generate something that makes sense. These people identified the

so-called DCGAN that is the first model able to produce some quite good quality for the images. They proposed

some principles for designing convolutional architecture specialized for images, the first model being able to

generate some larger resolution images. So, the generator architecture is something like: we have the input of the

network where you are really sampling from the uniform distribution, for instance, then you have a bunch of

convolutional layers, without any other type of layers in between, and they proposed also to use a than activation

in the last layer. Regarding the discriminator architecture, they only designed convolutional layers inside the

discriminator that is a classifier, a regular CNN; then they used Leaky ReLU activations and only one fully

connected layer before the softmax output (batch normalization after most layers) [in the following slides we can

see some examples of results obtained with DCGAN].

Another problem, with the stability of the architecture, is the evaluation of GAN performance, because whatever

we have a generation process we aren’t able and we don’t have a way to evaluate this. Let’s see two metrics.

One is Inception Score based one the idea that the GAN can produce images with a variety of recognizable object

classes, so there exists two criteria: a human, looking at each image, would be able to confidently determine what

is in there (saliency); or a human, looking at a set of various images, would say that the set has lots of different

objects (diversity). We will measure in terms of distribution and, in particular, we will consider two distribution:

one is the posterior label distribution p(y|x) , the other is the marginal distribution p(y) , and we are going to compare

them; the higher is the Inception Score, the two distributions differ more. But this approach has also two

disadvantages: a GAN that simply memorizes the training data (overfitting) or outputs a single image per class

(mode dropping) could still score well the return of the binding network.

Another metric is Fréchet Inception Distance, based on the idea that it fits simple distributions to statistics of feature

activations for real and generated data, so it estimates divergence parametrically [look better on slides].

There exists many issues with GAN training, some of them have already been solved. One of them is mode

collapse, in which at the end of our training process the generator was not able to capture globally what we are

training but was only able to concentrate on a small specific subset. There exists some tricks in order to solve this

mode collapse problem and also other problems, like batch norm that is a good idea inside the GAN because it

improves the training, or adding a loss for feature matching in order to expand the objective of our GAN from

beating the opponent to matching features in real images using the formula in the slide, or we can use the Mini-

batch Discrimination in which we append the similarity o(x) in one of the dense layers in the discriminator to

classify whether an image is real or generated [look also the following improvements].

What about the label information? We are just interested in the data, but if we have the label information, it would

be very stupid if I don't use that, so we can create a better dynamic in the training producing better and equality

features, this is called Conditional GAN (CGAN). We are also using the label for the generator, and we are also

using the label in the discriminator, so the objective function change if we use the label information such that the

formula is the same but in this case we have a conditional probability distribution x|y.

About the InfoGAN we can say that the label is not given, but it is treated as latent factor or code learned and

should have a meaningful and consistent effects on the output. The idea is that if you keep the code the same and

randomly change the noise, you get variations of the same digit [look the details in the slide].

The Wasserstein GAN (WGAN) is based on the idea that GAN can optimize the discriminator easier than the

generator, minimizing the GAN objective function with an optimal discriminator that is equivalent to minimizing

the Jensen-Shannon divergence. In this case, the objective function value is more meaningfully related to quality

of generator output.

Last improvement is the Least Square GAN (LSGAN), such that instead of using the logarithm we are using the

least square losses for obtaining better quality images that are more robust to mode collapse.

Can we feed something else to the generator and not just random noise for applying, for instance, an Image2Image

Translation? An idea is to use an architecture called Pix2Pix network, where instead of having random noise, we

have a transformation network that is still trained in an adversarial session. So, given the images of the input, we

train a generator such that this image will be translated such an image of the output domain because the

discriminator will access usually trying to distinguish if the images real or fake. There exists also an approach to

apply a Text2Image Synthesis, such that given a text description, the GAN are able to generate images closely

associated. We can also use the GANs to address fundamental tasks in computer vision, like SuperResolution.

Another improvement in the field is the CycleGAN, in which we want a GAN that is able to perform some cross-

domain transfer, such that a deep network G converts image x to y and another deep network F reconstructs the

image; so, we have two directions, and a mean square error is used to guide the training of G and F using also a

discriminator.

[Comments on last slide:] GAN is an approach for implicit density function, useful for the game-theoretic approach

such that it learns to generate samples from training data through a two-player game. An advantage is that it is

beautiful and state-of-the-art samples, but it can also be tricky and more unstable to train and cannot solve inference

queries.

Autoencoders to reconstruct the data and to learn features to initialize a supervised model; the question in

which we are interested to is if we can generate new images from an autoencoder. In principle yes, but in

practice no because they won’t produce anything meaningful, so the idea is to introduce a probabilistic

spin on autoencoders in order to sample from model for generating data. We want the ability to sample

from a probability distribution associated to our latent space and then in the decoder network we

implement a way to compute the conditional distribution that given the sample z from the latent space

will allow to generate the sample x. The intuition is that z is a latent factor meaningful for generating the

image x, and we want to estimate the optimal parameters q* of our network according to the maximum

likelihood. For representing this model, we have some parameters: p(z) that is a simple prior probability

that allows us to generate the complex conditional probability p(x|z) for generating images. So, we can

think to marginalize over dz and obtaining the maximum p q (x) , but this function is unfortunately

intractable because this marginalization makes our “life” difficult. Another problem is: the posterior

density of p q (z|x) is also intractable because we have p q (x) , so we have to think about another version

that will be another neural network.

The main intuition is given by Variational Approximation, such that in addition to decoder network

modeling p q (x|z) , we can define an additional encoder network q f (z|x) that approximates p q (z|x). This

allows us to derive a lower bound on the data likelihood that is tractable, which we can optimize, so-called

Variational lower bound (ELBO); so, we pass the input x in the Encoder computing q f (z|x) and we obtain

z that will enter in the Decoder for computing p q (x|z) that allows to obtain the reconstructed input x*.

Since we are modeling probabilistic generation of data, encoder and decoder networks are probabilistic,

so we are obtaining the mean and the covariance of z|x and x|z wrt two different parameters. Encoder and

Decoder networks also called Recognition/Inference and Generation networks [look the formulas].

When we are given a minibatch of our input data, we are training our additional Encoder network for

maximizing the likelihood lower bound and we are making sure that the second part of the formula is

maximized. Then, we need to sample x from the conditional distribution given the input data x and we

are going to use our Decoder network for maximizing the likelihood of the original input being

reconstructed also involving the sampling operation. Moreover, there exists a process called

Reparameterization that allows us to compute the backpropagation.

In the graphical comparison, we can see that AE suffers of some discontinuity in the latent space that

creates some problems; but, adding the KL term we can solve the problem obtaining the VAE where don’t

exist any discontinuities.

The researchers were challenged for exactly the same problem: generation of complex data, that could be

32x32 of CIFAR-10 dataset or a bit higher resolution images for the Labeled Faces in the Wild dataset.

In the case we have also the labels associated to our input data, we talk about the so-called Conditional

VAE, such that nothing changes wrt the previous formulas except to the replacing of p(x|z) with p(x|z,y)

and q(x|z) with q(x|z,y) [look an example of attribute-driven].

Some researchers later decided to put together the Variational AutoEncoders and the Generative

Adversarial Networks, creating the so-called VAE-GAN, because the VAEs are good with the Encoder

network given the input data and we can find the probability distribution for creating the samples in the

latent space, but it is going bad with the output because usually we obtain blurry images, while the GANs

using the discriminator have better control on the quality of their process.

[Look the final comparison table among PixelRNN/CNN, GAN and VAE].

13 - SEQUENCE MODELS

What is a sequence model? We will discuss about the image captioning and the role of attention inside the recurrent neural networks or for the purpose of image captioning, then we will shift to another application that is neural machine translation. We said already what is a recurrent neural network, repeat the just the most important things: the idea of capturing the dependencies among different words in a sentence or in general different elements of a sequence that is a through introducing a recurrence formula between different data representation at subsequent time, so this is the key formula of a recurrent neural network where we are learning the new state representation, modeling the dependencies among the different element of the sequence to this idea representation, and we are learning a nonlinear function that model these dependencies. About image captioning we have seen that given an image, we want to produce a caption implementing the neural network that comprises about a CNN to learn the features present in the image and the RNN to produce a sequence of words. What we have not seen is: can we push the network to look only at some relevant features in the image when our RNN are decoding some special words? It is that we want to obtain with the so-called Sequence models with attention. If we want to address the task of image caption given an image, we ask the neural network to produce a qualitative simulated sentence of describing the content of the image, putting together a CNN and an RNN to get something quite strong. This was demonstrated by the people cited in the slide in which they introduced the first deep neural network system for image captioning, whose idea was to capture visual features through a pre-trained CNN model and then perform the task of captioning that means predicting a certain word given the visual feature by using the LSTM. With the inference approach we can predict a bunch of most likely sentences because we want typically to operate in some form of post-processing step. A typical approach is the Beam search such that we maintain k top-scoring candidate sentences (according to sum of per-word log-likelihoods), and at each step, we generate all their successors and reduce to K (beam width). The BLEU Score (BiLingual Evaluation Understudy) is a metric originally developed for machine translation task that can be also adapted for image captioning. It is an algorithm for evaluating the quality of text which has been machine- translated from one natural language to another. Quality is considered to be the correspondence between a machine's output and that of a human such that "the closer a machine translation is to a professional human translation, the better it is". The BLEU Score is computed by the N-gram precision, so we want to count the number of matches in terms of N-grams between the candidate and reference translation, then divide by total number of N-grams in candidate translation and we clip counts by the maximum number of times an N-gram occurs in any reference translation. Maybe just using the BLEU score is not a good idea, for this reason the community has developed an alternative to score as well as being computing the score with different the size of N-grams precision in order to somehow have a comprehensive evaluation of the pros and cons of different methods. We can see an architecture for Captioning with Attention in which the authors forced an RNN to use only certain visual features when it predicts certain words because, for example, some visual features may be more relevant for predicting the word “bird”, while some other visual features can be misleading and the same if we have to predict the word “water”. The architecture maintains the CNN pre-trained at the beginning from which we have an output and then at each time we force our neural networks to predict not only the probability of a certain word to be predicted but also to predict the so-called Attention Map, that is a set of 14x14 numbers that tells us which areas of the image are more important for predicting a certain word. Its prediction is fed back to the next step by combining the feature map with the attention map into the so-called Context vector. We can see how this step is repeated many times. They were introduced for the purpose of improving the systems, of improving the performance of the caption. So, we obtain a feature map from the convolutional that represents the features in form of a matrix, while from the recurrent we obtain some probability distribution that indicates that at a certain point some area of the image are more important for predicting a certain symbol as the word, then we multiply both the matrices, and we obtain the Context vector. There exists two kinds of Attention Type for the context vector: Soft Attention such that the context vector is computed with a weighted combination of the grid of features and the attention map, and the Hard Attention in which we sample just one location z per time such that z is a random variable taking on a certain value with certain probabilities that requires a more sophisticated training [we can see a graphical difference of how they act and their results in a table]. A big field that is paying a lot of attention is Neural Machine Translation that is mostly used for improving Google Translate. How do we obtain these results? It is based on the Seq2Seq learning such that can be used to perform end-to- end translation. It shows the promise of Neural Machine Translation (NMT) over Statistical Machine Translation (SMT) in which were proposed a 2 Deep LSTM architecture to do language translation from English to French: Encoder that takes the input and maps it into a fixed dimension vector, and Decoder that takes the fixed vector and maps it to an output sequence. We can see from the results they used some tricks, by using deeper architecture with large size of beam. We assume also that the latent representation is able to capture entire phrases. In 2014, ACL’s group proposed a different architecture by introducing the context vector for decoding words, where an encoder RNN learns a fixed length vector representation (context) from variable length sequence input while the decoder RNN (similar to encoder architecture) outputs a variable length sequence output from the fixed length vector