Deep Learning cheatsheet

Neural Networks

Neural networks are a class of models that are built with layers. Commonly used types of neural networks include convolutional and recurrent neural networks.
Architecture ― The vocabulary around neural networks architectures is described in the figure below:
Illustration
By noting i the ith layer of the network and j the jth hidden unit of the layer, we have:
zj[i]=wj[i]Tx+bj[i]
where we note wbz the weight, bias and output respectively.

Activation function ― Activation functions are used at the end of a hidden unit to introduce non-linear complexities to the model. Here are the most common ones:
SigmoidTanhReLULeaky ReLU
g(z)=11+ezg(z)=ezezez+ezg(z)=max(0,z)g(z)=max(ϵz,z)
with ϵ1
IllustrationIllustrationIllustrationIllustration

Cross-entropy loss ― In the context of neural networks, the cross-entropy loss L(z,y) is commonly used and is defined as follows:
L(z,y)=[ylog(z)+(1y)log(1z)]

Learning rate ― The learning rate, often noted α or sometimes η, indicates at which pace the weights get updated. This can be fixed or adaptively changed. The current most popular method is called Adam, which is a method that adapts the learning rate.

Backpropagation ― Backpropagation is a method to update the weights in the neural network by taking into account the actual output and the desired output. The derivative with respect to weight w is computed using chain rule and is of the following form:
L(z,y)w=L(z,y)a×az×zw
As a result, the weight is updated as follows:
wwαL(z,y)w

Updating weights ― In a neural network, weights are updated as follows:
  • Step 1: Take a batch of training data.
  • Step 2: Perform forward propagation to obtain the corresponding loss.
  • Step 3: Backpropagate the loss to get the gradients.
  • Step 4: Use the gradients to update the weights of the network.

Dropout ― Dropout is a technique meant at preventing overfitting the training data by dropping out units in a neural network. In practice, neurons are either dropped with probability p or kept with probability 1p.

Convolutional Neural Networks

Convolutional layer requirement ― By noting W the input volume size, F the size of the convolutional layer neurons, P the amount of zero padding, then the number of neurons N that fit in a given volume is such that:
N=WF+2PS+1

Batch normalization ― It is a step of hyperparameter γ,β that normalizes the batch {xi}. By noting μB,σB2 the mean and variance of that we want to correct to the batch, it is done as follows:
xiγxiμBσB2+ϵ+β
It is usually done after a fully connected/convolutional layer and before a non-linearity layer and aims at allowing higher learning rates and reducing the strong dependence on initialization.

Recurrent Neural Networks

Types of gates ― Here are the different types of gates that we encounter in a typical recurrent neural network:
Input gateForget gateGateOutput gate
Write to cell or not?Erase a cell or not?How much to write to cell?How much to reveal cell?

LSTM ― A long short-term memory (LSTM) network is a type of RNN model that avoids the vanishing gradient problem by adding 'forget' gates.

For a more detailed overview of the concepts above, check out the Deep Learning cheatsheets!

Reinforcement Learning and Control

The goal of reinforcement learning is for an agent to learn how to evolve in an environment.

Definitions

Markov decision processes ― A Markov decision process (MDP) is a 5-tuple (S,A,{Psa},γ,R) where:
  • S is the set of states
  • A is the set of actions
  • {Psa} are the state transition probabilities for sS and aA
  • γ[0,1[ is the discount factor
  • R:S×AR or R:SR is the reward function that the algorithm wants to maximize

Policy ― A policy π is a function π:SA that maps states to actions.
Remark: we say that we execute a given policy π if given a state s we take the action a=π(s).

Value function ― For a given policy π and a given state s, we define the value function Vπ as follows:
Vπ(s)=E[R(s0)+γR(s1)+γ2R(s2)+...|s0=s,π]

Bellman equation ― The optimal Bellman equations characterizes the value function Vπ of the optimal policy π:
Vπ(s)=R(s)+maxaAγsSPsa(s)Vπ(s)
Remark: we note that the optimal policy π for a given state s is such that:
π(s)=argmaxaAsSPsa(s)V(s)

Value iteration algorithm ― The value iteration algorithm is in two steps:
1) We initialize the value:
V0(s)=0
2) We iterate the value based on the values before:
Vi+1(s)=R(s)+maxaA[sSγPsa(s)Vi(s)]

Maximum likelihood estimate ― The maximum likelihood estimates for the state transition probabilities are as follows:
Psa(s)=#times took action a in state s and got to s#times took action a in state s

Q-learning ― Q-learning is a model-free estimation of Q, which is done as follows:
Q(s,a)Q(s,a)+α[R(s,a,s)+γmaxaQ(s,a)Q(s,a)]

Post a Comment

0 Comments