Depth playgroundLaboratorio della profondità

A stack of up to 30 fully connected layers of the same width, trained in the page on a data set of the TensorFlow Playground, trains or not according to how the signal crosses the layers: with weights too small the activations and the gradients shrink by a nearly constant factor at every layer, while with weights too large the \(\tanh\) and sigmoid units saturate and the network computes a function that changes erratically over the plane. The initializations of Glorot and Bengio and of He et al. choose the variance of the weights so that the variance of the activations stays about constant from layer to layer; normalization restores it at every layer, and residual connections give the gradient a path around each layer.

Una pila di fino a 30 strati completamente connessi della stessa larghezza, addestrata nella pagina su un data set del TensorFlow Playground, si addestra o no secondo come il segnale attraversa gli strati: con pesi troppo piccoli le attivazioni e i gradienti si riducono di un fattore quasi costante a ogni strato, mentre con pesi troppo grandi le unità \(\tanh\) e sigmoidi saturano e la rete calcola una funzione che varia in modo irregolare sul piano. Le inizializzazioni di Glorot e Bengio e di He et al. scelgono la varianza dei pesi in modo che la varianza delle attivazioni resti circa costante da uno strato all'altro; la normalizzazione la ripristina a ogni strato, e le connessioni residue danno al gradiente un percorso che aggira ciascuno strato.

presetsconfigurazioni

LayerStrato \(l\)

\(a_l = W_l\,h_{l-1} + b_l\)\(W_l\) is \(n_{\rm out} \times n_{\rm in}\), \(h_0 = x / 3\)\(W_l\) è \(n_{\rm out} \times n_{\rm in}\), \(h_0 = x / 3\)
\(h_l = \phi\big(N(a_l)\big)\)\(\phi\) the activation, \(N\) the normalization\(\phi\) l'attivazione, \(N\) la normalizzazione

Initialization ofInizializzazione di \(W_l\)

\(W_{ij} \sim \mathcal N(0, 1)\)
\(W_{ij} \sim \mathcal N(0, 10^{-4})\)
\(\operatorname{Var} W_{ij} = \dfrac{2}{n_{\rm in} + n_{\rm out}}\)Glorot and BengioGlorot e Bengio
\(\operatorname{Var} W_{ij} = \dfrac{2}{n_{\rm in}}\)He et al., for ReLUHe et al., per ReLU

NormalizationNormalizzazione \(N\)

\(N(a) = a\)
\(N(a)_j = \gamma_j\,\dfrac{a_j - \mu_j}{\sqrt{\sigma_j^2 + \epsilon}} + \beta_j\)batch norm: \(\mu_j, \sigma_j^2\) of unit \(j\) over the minibatchbatch norm: \(\mu_j, \sigma_j^2\) dell'unità \(j\) sul minibatch
layer norm: the same, with \(\mu, \sigma^2\) over the units of one examplelayer norm: la stessa, con \(\mu, \sigma^2\) sulle unità di un esempio

Residual connectionConnessione residua

\(h_l = h_{l-1} + F(h_{l-1})\)\(F(h) = \phi(N(W_l h + b_l))\), for \(l \ge 2\); then \(\partial h_l / \partial h_{l-1} = I + \partial F / \partial h\)\(F(h) = \phi(N(W_l h + b_l))\), per \(l \ge 2\); quindi \(\partial h_l / \partial h_{l-1} = I + \partial F / \partial h\)

The probability of the violet class over the plane \([-6, 6]^2\), with the training points (filled); the loss of the training set (solid) and of the test set (dashed), and the dotted line at \(\log 2\), which is the loss of a constant answer.La probabilità della classe viola sul piano \([-6, 6]^2\), con i punti di addestramento (pieni); la loss dell'insieme di addestramento (continua) e del test set (tratteggiata), e la linea punteggiata a \(\log 2\), che è la loss di una risposta costante.
training lossloss di addestramento
test lossloss di test
test accuracyaccuratezza sul test set
Layer by layer, from the input (top) to the output, on the 200 training points: the histogram of the activations \(h_l\) over (violet), and that of \(\log_{10} |\partial L / \partial (W_l)_{ij}|\) over the entries of \(W_l\) (gold), the tick marking the norm of the whole gradient of \(W_l\); values beyond the ends fall in the darker end bins.Strato per strato, dall'ingresso (in alto) all'uscita, sui 200 punti di addestramento: l'istogramma delle attivazioni \(h_l\) su (in viola), e quello di \(\log_{10} |\partial L / \partial (W_l)_{ij}|\) sugli elementi di \(W_l\) (in oro), con la tacca che segna la norma dell'intero gradiente di \(W_l\); i valori oltre gli estremi cadono nelle classi estreme più scure.
The first unit of every layer over the plane, on the scale of the histograms: a unit whose signal has vanished takes the color of zero, a saturated one is violet or gold almost everywhere.La prima unità di ogni strato sul piano, nella scala degli istogrammi: un'unità il cui segnale è svanito prende il colore dello zero, una saturata è viola o oro quasi ovunque.