concept NN in category Keras

This is an excerpt from Manning's book Probabilistic Deep Learning: With Python, Keras and TensorFlow Probability.
Abbreviation / Term
Definition / Meaning
Aleatoric Uncertainty
Data inherent uncertainty which cannot be further reduced. For example, you can’t tell on which side a coin will land.
API
Application interface
Bayesian Mantra
The posterior is proportional to the likelihood times the prior.
BNN
Bayesian Neural Networks, NN with their weights being replaced by distributions. Solved with VI or MC-Dropout.
Bayesian Probabilistic Models
Probabilistic models that can state their epistemic uncertainty by characterizing all parameters of a distribution.
Bayesian View of Statistics
In the Bayesian view on statistics, the parameters
are not fixed but follow a distribution.
Bayesian Theorem
, this famous formula tells how to invert a conditional probability
Bayesian learning
, this formula tells you how to determine the posterior
from the likelihood
, the prior
and the marginal likelihood (aka evidence)
. It is a special form of the Bayesian theorem with
and
, with
being the parameters of a model and
the data.
Backpropagation
Method to efficiently calculate the gradients of the loss function w.r.t. the weights of a NN.
Bijectors
TFP package for invertible (bijective) functions needed for NF.
CIFAR-10
A popular benchmark data containing 60,000 32x32 color images of 10 classes.
CNN
Convolutional Neural Networks, NN especially suited for vision applications.
Computational Graph
A graph which encodes all calculations in a NN.
CPD
Conditional Probability Distribution. We also sloppily call the density
of an outcome y (e.g. the age of a person) given some input x (e.g. the image of a person) a CPD.
Cross Entropy
Another name for NLL in the case of classification tasks.
Deterministic Model
Non-Probabilistic Model, returning no distribution for the outcome but only one best guess.
Dropout
Dropout refers to randomly deleting nodes in a NN. Dropout during training yields typically NNs that show reduced overfitting. Performing Dropout also during test time (see MC dropout) is interpreted as an approximation of a BNN.
DL
Deep Learning
Extrapolation
Leaving the range of data with which a model was trained.
Epistemic Uncertainty
Uncertainty of the model caused by the uncertainty about the model parameters, which can in principle be reduced by providing more data.
fcNN
Fully connected neural networks.
GLOW
A certain CNN network based on NF which generates realistic looking faces.
ImageNet
A famous data set with 1 Million labeled images of 1000 classes.
Jacobian matrix
The Jacobian matrix of a multidimensional function or transformation in several variables is the matrix of all its first-order partial derivatives.
Jacobian Determinant
The determinant of the Jacobian matrix. It is used to calculate the change in volume happening in transformations, needed for NF.
Keras
Keras is a high-level neural networks API which we use in this book in conjunction with TensorFlow.
KL-Divergence
A kind measure for the distance between two PDFs.
Likelihood
The probability
that sampling from a density specified by a parameter value
produces the data.
Loss Function
A function which quantifies the badness of a model and which is optimized during the training of a DL model.
MAE
Mean Absolute Error. The MAE is a performance measure, which is computed as the mean of absolute values of the residuals. It is not sufficient to quantify the performance of probabilistic models (here the NLL should be used as performance measure).
MaxLike
Maximum Likelihood
MaxLike learning
A likelihood based method to determine the parameter values
of a model, for example the weight in a NN. The objective to maximize the likelihood of the observed data
. This corresponds to minimizing the NLL.
ML
Machine Learning
MC dropout
Monte Carlo Dropout refers to dropout during test time. A method that is interpreted as approximation to a BNN.
MNIST
More correctly the MNIST database of handwritten digits. A dataset of 60,000 28x28 greyscaled 10 classes (the digits 0-9).
MSE
Mean Squared Error. The MSE is a performance measure, which is computed as the average of the squared residuals. It is not sufficient to quantify the performance of For probabilistic models (here the NLL should be used as a performance measure).
NF
Normalizing Flow. NF is a NN based method to fit complex probability distributions.
NLL
Negative Log-Likelihood. The NLL is used as a loss function when fitting probabilistic models.
The NLL on the validation set is the optimal measure to quantify the prediction performance of a probabilistic model.NN
Neural Network
Observed outcome
The observed outcome or “
-value” which is measured for a certain instance i. In a probabilistic model, we aim to predict a CPD for y based on some features that characterize the instance i. Sometimes
is also bewilderingly called “true” value. We don’t like that expression since in the presence of aleatoric uncertainty there is no true outcome.
Probability density function. The PDF is also sometimes referred to as probability density distribution. See CPD for a conditional version.
PixelCNN++
A certain CNN model capturing the probability distribution of pixel values. The “++ version” uses advanced CPDs for performance.
Posterior
The distribution
of a parameter
after seeing the data D.
Posterior predictive distribution
The CPD
given the data D which results from a Bayesian probabilistic model.
Prediction Interval
Interval in which a certain fraction, typically 95%, of all data are expected.
Prior
The distribution
which is assigned to a model parameter
before seeing any data D.
Probabilistic Model
A model returning a distribution for the outcome.
Residuals
Differences between the the observed value
and the deterministic model output
(the expected value of the outcome).
RMSE
Root Mean Squared Error, the square root of the MSE.
RealNVP
A specific NF model called Real Non-Volume Preserving.
softmax
An activation function enforcing that the output of the neural network sums up to 1 and can be interpreted as a probability.
softplus
An activation function, which after it’s application ensures positive values
SGD
Stochastic Gradient Descent
Tensor
Multidimensional array, the main data structure in deep learning
TF
TensorFlow is a low-level library which is used in this book for DL.
The big lie of DL
The assumption P(Train)=P(Test), that the test data stems from the same distributions as the training data. In many DL / ML applications, this is assumed but often not true.
TFP
TensorFlow Probability add-on to TF facilitating probabilistic modeling of DL.
VGG16
A traditional CNN with a specific architecture that was on second rank of the imageNet competition in 2014. It is often used with weights that resulted after training on the imageNet data to extract feature from an image.
VI
Variational Inference is a method for which it can be shown that it yields an approximation to a BNN.
w.r.t.
with respect to
WaveNet
A specific NN model for text to speech.
ZIP
Zero Inflated Poisson a special distribution for count data taking care of an excess of the value 0.
As an example, a well trained network would have a high value for p1 if the training example is from class 1 (fake banknote). What is the probability for the training set as a whole? Here we make the assumption that all the examples in the training are independent of each other. Then the probability of the whole training data set is simply the product of the individual probabilities. For example: Imagine you throw a regular die twice and you ask for the probability to have a one in the first throw and a two in the second. This is simply
since the throws are independent. So the likelihood of the whole training set is the product of all individual examples. So we go one training example after another and look at what is the probability for the true class and then take product of all those probabilities. We could also order the probabilities as follows: First we take the real banknotes (for which y=0) and multiply the predictions p0 together. Then, we take the fake ones and multiply p1 together. Let’s say you have five banknotes in your training set. The first three examples come from real banknotes, the last two examples from fake ones and you get from the NN for all banknotes the probabilities to belong to class zero (
) or to class one (
). Then the likelihood of all five banknotes is:
The NN with fixed weights in figure 4.5 outputs the probabilities for all possible class labels y when feeding in a certain input x. This can be written als probability distribution for the outcome Y which depends on the input value x and the weights of the NN.
![]()
states that the random variable
takes specific values
. You can further read the vertical bar as “with given” or “conditioned on” and behind the bar comes all information which is given and is used to determine the probability of the variable in front of the bar. Here you need to know the value of the input
and the weights
of the NN to compute the outputs of the NN which are p0 and p1. Because the probability distribution depends on x, it is called a conditional probability distribution (CPD). Often you see a simpler version of this equation which skips the part behind the bar (either only
or both
) and assumes that this is self-evident.
In listing 4.5 you see how you can simulate some data from a sinus function and fit a NN with 3 hidden layers and an MSE loss to the data, resulting in a well fitting non-linear curve (see figure 4.17).
listing 4.5 A fully connected NN with 3 hidden layers to model non-linear relation ships using the MSE loss
x,y = create_random_data(n=300) #A model = Sequential() #B model.add(Dense(1, activation='relu', batch_input_shape=(None, 1))) model.add(Dense(20, activation='relu')) model.add(Dense(50,activation='relu')) model.add(Dense(20, activation='relu')) model.add(Dense(1, activation='linear')) opt = optimizers.Adam(lr=0.0001) model.compile(loss='mean_squared_error',optimizer=opt) history=model.fit(x, y, batch_size=n, epochs=10000, verbose=0, ) # C # A Create some random data see figure 4.17 # B define the fully connected NN with 3 hidden layers and relu activations # C fit the NN using the MSE loss