Aprendizaje profundo - Redes recurrentes
Transcript of Aprendizaje profundo - Redes recurrentes
![Page 1: Aprendizaje profundo - Redes recurrentes](https://reader036.fdocuments.es/reader036/viewer/2022073020/62e433776b799413872a64a5/html5/thumbnails/1.jpg)
Aprendizaje profundo
Redes recurrentes
Gibran Fuentes-Pineda
Septiembre 2019
1
![Page 2: Aprendizaje profundo - Redes recurrentes](https://reader036.fdocuments.es/reader036/viewer/2022073020/62e433776b799413872a64a5/html5/thumbnails/2.jpg)
Modelando secuencias
Imagen tomada de Karpathy 2015 (http://karpathy.github.io/2015/05/21/rnn-effectiveness/)
2
![Page 3: Aprendizaje profundo - Redes recurrentes](https://reader036.fdocuments.es/reader036/viewer/2022073020/62e433776b799413872a64a5/html5/thumbnails/3.jpg)
Redes recurrentes
• Red (o capas) con retro-alimentacion en sus conexiones
Imagen tomada de Colah 2015 (http://colah.github.io/posts/2015-08-Understanding-LSTMs/)
3
![Page 4: Aprendizaje profundo - Redes recurrentes](https://reader036.fdocuments.es/reader036/viewer/2022073020/62e433776b799413872a64a5/html5/thumbnails/4.jpg)
Elementos basicos
1. Entradas en cada instante de tiempo t (x(t))
2. Estados en cada instante de tiempo t (C(t))
3. Salidas en cada instante de tiempo t (h(t))
Imagen tomada de Colah 2015 (http://colah.github.io/posts/2015-08-Understanding-LSTMs/)
4
![Page 5: Aprendizaje profundo - Redes recurrentes](https://reader036.fdocuments.es/reader036/viewer/2022073020/62e433776b799413872a64a5/html5/thumbnails/5.jpg)
Tipos de retroalimentacion
1. Salida anterior (h(t−1))
2. Estado anterior (C(t−1))
3. Salida y estado anterior (h(t−1) y C(t−1))
Imagen tomada de Colah 2015 (http://colah.github.io/posts/2015-08-Understanding-LSTMs/)
5
![Page 6: Aprendizaje profundo - Redes recurrentes](https://reader036.fdocuments.es/reader036/viewer/2022073020/62e433776b799413872a64a5/html5/thumbnails/6.jpg)
Celda recurrente basica
• Su estado en cada paso t esta dado por
C(t) = tanh (WC · [C(t−1), x(t)] + bC )
6
![Page 7: Aprendizaje profundo - Redes recurrentes](https://reader036.fdocuments.es/reader036/viewer/2022073020/62e433776b799413872a64a5/html5/thumbnails/7.jpg)
Red neuronal con celdas recurrentes
• Tıpipamente contiene celdas recurrentes en conjunto con
otras capas
• La salida de una celda puede alimentar otras capas u otras
celdas
• Un clasificador simple
h(t) =WhC(t) + bh
y(t) =softmax(h(t))
7
![Page 8: Aprendizaje profundo - Redes recurrentes](https://reader036.fdocuments.es/reader036/viewer/2022073020/62e433776b799413872a64a5/html5/thumbnails/8.jpg)
Ejemplo: modelo de lenguaje a nivel sımbolo
Imagen tomada de Karpathy 2015 (http://karpathy.github.io/2015/05/21/rnn-effectiveness/)
8
![Page 9: Aprendizaje profundo - Redes recurrentes](https://reader036.fdocuments.es/reader036/viewer/2022073020/62e433776b799413872a64a5/html5/thumbnails/9.jpg)
Despliegue de celdas
• Una celda recurrente para una secuencia de t valores, se
puede desplegar en t capas con parametros identicos
Imagen tomada de Colah 2015 (http://colah.github.io/posts/2015-08-Understanding-LSTMs/)
9
![Page 10: Aprendizaje profundo - Redes recurrentes](https://reader036.fdocuments.es/reader036/viewer/2022073020/62e433776b799413872a64a5/html5/thumbnails/10.jpg)
Modelando dependencias a corto plazo
• En teorıa una red recurrente basica puede modelar
dependencias a corto y largo plazo
Imagen tomada de Colah 2015 (http://colah.github.io/posts/2015-08-Understanding-LSTMs/)
10
![Page 11: Aprendizaje profundo - Redes recurrentes](https://reader036.fdocuments.es/reader036/viewer/2022073020/62e433776b799413872a64a5/html5/thumbnails/11.jpg)
El problema de la memoria a largo plazo
• En practica es muy difıcil entrenarlas para tareas con
dependencias a largo plazo
Imagen tomada de Colah 2015 (http://colah.github.io/posts/2015-08-Understanding-LSTMs/)
11
![Page 12: Aprendizaje profundo - Redes recurrentes](https://reader036.fdocuments.es/reader036/viewer/2022073020/62e433776b799413872a64a5/html5/thumbnails/12.jpg)
Elementos de una celda recurrente estandar
• Una celda basica desplegada recibe como entrada x(t) y el
estado anterior C(t−1) y produce el nuevo estado C(t)
Imagen tomada de Colah 2015 (http://colah.github.io/posts/2015-08-Understanding-LSTMs/)
12
![Page 13: Aprendizaje profundo - Redes recurrentes](https://reader036.fdocuments.es/reader036/viewer/2022073020/62e433776b799413872a64a5/html5/thumbnails/13.jpg)
Memorias a corto y largo plazo
• Agregan elementos internos a la celda basica que permiten
capturar dependencias a corto y largo plazo
Imagen tomada de Colah 2015 (http://colah.github.io/posts/2015-08-Understanding-LSTMs/)
13
![Page 14: Aprendizaje profundo - Redes recurrentes](https://reader036.fdocuments.es/reader036/viewer/2022073020/62e433776b799413872a64a5/html5/thumbnails/14.jpg)
LSTM: salida de la capa anterior
• Agrega o elimina elementos del estado anterior de la celda
C(t−1) basado en transformacion de la entrada actual x(t) y el
estado oculto anterior h(t−1)
Imagen tomada de Colah 2015 (http://colah.github.io/posts/2015-08-Understanding-LSTMs/)
14
![Page 15: Aprendizaje profundo - Redes recurrentes](https://reader036.fdocuments.es/reader036/viewer/2022073020/62e433776b799413872a64a5/html5/thumbnails/15.jpg)
LSTM: compuerta de olvido
• Determina que olvidar del estado de la celda C(t−1) y en que
proporcion a partir de la entrada actual x(t) y estado oculto
anterior h(t−1)
f(t) = σ(Wf · [h(t−1), x(t)] + bf )
Imagen tomada de Colah 2015 (http://colah.github.io/posts/2015-08-Understanding-LSTMs/)
15
![Page 16: Aprendizaje profundo - Redes recurrentes](https://reader036.fdocuments.es/reader036/viewer/2022073020/62e433776b799413872a64a5/html5/thumbnails/16.jpg)
LSTM: computerta de entrada
• Determina que agregar al estado de la celda C(t−1) y en que
proporcion a partir de la entrada actual x(t) y estado oculto
anterior h(t−1)
i(t) = σ(Wi · [h(t−1), x(t)] + bi )
C(t) = tanh(WC · [h(t−1), x(t)] + bC )
Imagen tomada de Colah 2015 (http://colah.github.io/posts/2015-08-Understanding-LSTMs/)
16
![Page 17: Aprendizaje profundo - Redes recurrentes](https://reader036.fdocuments.es/reader036/viewer/2022073020/62e433776b799413872a64a5/html5/thumbnails/17.jpg)
LSTM: nuevo estado
• El nuevo estado de la celda se obtiene como una combinacion
de la salida de la compuerta de olvido f(t) y las salidas i(t) y
C(t) de la compuerta de entrada
C(t) = f(t) ∗ C(t−1) + i(t) ∗ C(t)
Imagen tomada de Colah 2015 (http://colah.github.io/posts/2015-08-Understanding-LSTMs/)
17
![Page 18: Aprendizaje profundo - Redes recurrentes](https://reader036.fdocuments.es/reader036/viewer/2022073020/62e433776b799413872a64a5/html5/thumbnails/18.jpg)
LSTM: computerta de salida
• El siguiente estado oculto h(t) se obtiene como una
combinacion de la entrada actual x(t), el estado oculto
anterior h(t−1) y el nuevo estado de la celda C(t)
o(t) = σ(Wo [ht−1, xt ] + bo)
h(t) = o(t) ∗ tanh (C(t))
Imagen tomada de Colah 2015 (http://colah.github.io/posts/2015-08-Understanding-LSTMs/)
18
![Page 19: Aprendizaje profundo - Redes recurrentes](https://reader036.fdocuments.es/reader036/viewer/2022073020/62e433776b799413872a64a5/html5/thumbnails/19.jpg)
Gated Recurrent Unit
• Combina compuertas de olvido y entrada en una sola y agrega
otras conexiones y elementos
Imagen tomada de Colah 2015 (http://colah.github.
io/posts/2015-08-Understanding-LSTMs/)
z(t) =σ(Wz · [h(t−1), x(t)] + bz)
r(t) =σ(Wr · [h(t−1), x(t)] + br )
h(t) = tanh(W · [r(t) ∗ h(t−1), x(t)] + b)
h(t) =(1 − z(t)) ∗ h(t−1) + z(t) ∗ h(t−1)
19
![Page 20: Aprendizaje profundo - Redes recurrentes](https://reader036.fdocuments.es/reader036/viewer/2022073020/62e433776b799413872a64a5/html5/thumbnails/20.jpg)
Retropropagacion en el tiempo
Imagen tomada de Wikipedia (https://en.wikipedia.org/wiki/Backpropagation_through_time)
20
![Page 21: Aprendizaje profundo - Redes recurrentes](https://reader036.fdocuments.es/reader036/viewer/2022073020/62e433776b799413872a64a5/html5/thumbnails/21.jpg)
Redes recurrentes apiladas
Imagen tomada de: Christopher Bourez. Deep Learning with Theano, 2017.
21
![Page 22: Aprendizaje profundo - Redes recurrentes](https://reader036.fdocuments.es/reader036/viewer/2022073020/62e433776b799413872a64a5/html5/thumbnails/22.jpg)
RNR Bidireccional
Imagen tomada de Goodfellow et al. 2016 (http://www.deeplearningbook.org/contents/rnn.html)
22
![Page 23: Aprendizaje profundo - Redes recurrentes](https://reader036.fdocuments.es/reader036/viewer/2022073020/62e433776b799413872a64a5/html5/thumbnails/23.jpg)
Modelos secuencia a secuencia
Imagen derivada de https://www.tensorflow.org/tutorials/seq2seq
23