![Page 1: Deep Learning: The Third Wave the Neural Networks](https://reader035.vdocument.in/reader035/viewer/2022081604/62c1cb600813c7640b7f2414/html5/thumbnails/1.jpg)
Redes convolucionales para procesamiento de imágenes
Mariano Rivera Meraz Alan G. Reyes Figueroa
M. Rivera – A. G. Reyes, PI 2018
Taller Keras
![Page 2: Deep Learning: The Third Wave the Neural Networks](https://reader035.vdocument.in/reader035/viewer/2022081604/62c1cb600813c7640b7f2414/html5/thumbnails/2.jpg)
Convolución
Procesamiento de imágenes
•El procesamiento espacial consiste de estimar el valor de un píxel en función de sus vecinos.
• La idea: mover una máscara: un rectángulo (con lados de tamaño impar) u otra forma. Los valores de los píxeles se calculan usando los valores de los píxeles en la máscara.
• La combinación de una máscara y una función se llama un filtro.
![Page 3: Deep Learning: The Third Wave the Neural Networks](https://reader035.vdocument.in/reader035/viewer/2022081604/62c1cb600813c7640b7f2414/html5/thumbnails/3.jpg)
Convolución
![Page 4: Deep Learning: The Third Wave the Neural Networks](https://reader035.vdocument.in/reader035/viewer/2022081604/62c1cb600813c7640b7f2414/html5/thumbnails/4.jpg)
Convolución •A la máscara se
asignan pesos 𝑚𝑖𝑗 = 𝑚(𝑖, 𝑗).
• Los píxeles de la imagens tienen valores 𝑝𝑘𝑙 = 𝑝(𝑘, 𝑙).
•El nuevo valor 𝑝𝑖𝑗 se calcula como una función de los 𝑚𝑘𝑙 y los 𝑝𝑘𝑙.
![Page 5: Deep Learning: The Third Wave the Neural Networks](https://reader035.vdocument.in/reader035/viewer/2022081604/62c1cb600813c7640b7f2414/html5/thumbnails/5.jpg)
Filtros y convolución
(correlación)
![Page 6: Deep Learning: The Third Wave the Neural Networks](https://reader035.vdocument.in/reader035/viewer/2022081604/62c1cb600813c7640b7f2414/html5/thumbnails/6.jpg)
Filtros y convolución
![Page 7: Deep Learning: The Third Wave the Neural Networks](https://reader035.vdocument.in/reader035/viewer/2022081604/62c1cb600813c7640b7f2414/html5/thumbnails/7.jpg)
Filtros y convolución
![Page 8: Deep Learning: The Third Wave the Neural Networks](https://reader035.vdocument.in/reader035/viewer/2022081604/62c1cb600813c7640b7f2414/html5/thumbnails/8.jpg)
Ejemplos
1 1 1
1 1 1
1 1 1
𝐻 =1
9 Filtro de medias.
Imagen original
Imagen filtrada
19 1
9 19
19 1
9 19
19 1
9 19
=
![Page 9: Deep Learning: The Third Wave the Neural Networks](https://reader035.vdocument.in/reader035/viewer/2022081604/62c1cb600813c7640b7f2414/html5/thumbnails/9.jpg)
Ejemplos
𝐻 =1
𝑘2 Filtro de medias.
1 1 … 1
1 1 … 1
… … …
1 1 … 1 𝑘 × 𝑘
Imagen original
Imagen filtrada (25 x 25)
![Page 10: Deep Learning: The Third Wave the Neural Networks](https://reader035.vdocument.in/reader035/viewer/2022081604/62c1cb600813c7640b7f2414/html5/thumbnails/10.jpg)
Ejemplos
1 0 -1
1 0 -1
1 0 -1
𝐻𝑥 =
Filtros de gradiente.
1 1 1
0 0 0
-1 -1 -1
𝐻𝑦 =
Imagen original
Imagen filtrada 𝐻𝑥
Imagen filtrada 𝐻𝑦
![Page 11: Deep Learning: The Third Wave the Neural Networks](https://reader035.vdocument.in/reader035/viewer/2022081604/62c1cb600813c7640b7f2414/html5/thumbnails/11.jpg)
Ejemplos
0 -1 0
-1 8 -1
0 -1 0
𝐻𝑥 =1
4 Filtro de sharpening.
Imagen original
Imagen filtrada
![Page 12: Deep Learning: The Third Wave the Neural Networks](https://reader035.vdocument.in/reader035/viewer/2022081604/62c1cb600813c7640b7f2414/html5/thumbnails/12.jpg)
Imagen original
Imagen filtrada
0 -1 0
-1 4 -1
0 -1 0
𝐻 = Filtro laplaciano.
(detección de bordes)
Ejemplos
![Page 13: Deep Learning: The Third Wave the Neural Networks](https://reader035.vdocument.in/reader035/viewer/2022081604/62c1cb600813c7640b7f2414/html5/thumbnails/13.jpg)
Padding
![Page 14: Deep Learning: The Third Wave the Neural Networks](https://reader035.vdocument.in/reader035/viewer/2022081604/62c1cb600813c7640b7f2414/html5/thumbnails/14.jpg)
Padding
En Keras, hay dos valores para el parámetro padding: 𝐻 filtro de tamaño (2𝑘 + 1) × (2𝑘 + 1).
𝐼 imagen de tamaño 𝑚 × 𝑛.
• padding = ‘valid’. Sólo recorre el filtro en las posiciones válidas, donde no se sale del dominio de la imagen. La imagen de salida es más reducida 𝒎− 𝟐𝒌 × (𝒏 − 𝟐𝒌).
•padding = ‘same’. Crea una región que extiende la imagen, para recorrer la máscara sobre todos los píxeles. La imagen de salida es del mismo tamaño 𝒎× 𝒏.
![Page 15: Deep Learning: The Third Wave the Neural Networks](https://reader035.vdocument.in/reader035/viewer/2022081604/62c1cb600813c7640b7f2414/html5/thumbnails/15.jpg)
Padding
padding = ‘same’
padding = ‘valid’
![Page 16: Deep Learning: The Third Wave the Neural Networks](https://reader035.vdocument.in/reader035/viewer/2022081604/62c1cb600813c7640b7f2414/html5/thumbnails/16.jpg)
Stride
Tamaño de salto en la convolución. En Keras, el default es (1,1).
![Page 17: Deep Learning: The Third Wave the Neural Networks](https://reader035.vdocument.in/reader035/viewer/2022081604/62c1cb600813c7640b7f2414/html5/thumbnails/17.jpg)
Pooling (sub-muestreo)
Las capas de Pooling, hacen un muestreo sistemático de los píxeles en la imagen.
En Keras, usa el parámetro Pool_size = 2,2 .
La imagen de salida se reduce en un factor de Pool_size.
También parámetro stride. En Keras, stride = pool_size.
![Page 18: Deep Learning: The Third Wave the Neural Networks](https://reader035.vdocument.in/reader035/viewer/2022081604/62c1cb600813c7640b7f2414/html5/thumbnails/18.jpg)
Redes neuronales convolucionales
•Neurona = filtro.
•Pesos = pesos de
cada filtro.
![Page 19: Deep Learning: The Third Wave the Neural Networks](https://reader035.vdocument.in/reader035/viewer/2022081604/62c1cb600813c7640b7f2414/html5/thumbnails/19.jpg)
Redes neuronales convolucionales
Una red convolucional integra dos partes
•Capas convolucionales + Capas Pooling: extractor de rasgos.
•Capas densas: clasificador.
![Page 20: Deep Learning: The Third Wave the Neural Networks](https://reader035.vdocument.in/reader035/viewer/2022081604/62c1cb600813c7640b7f2414/html5/thumbnails/20.jpg)
Redes neuronales convolucionales
![Page 21: Deep Learning: The Third Wave the Neural Networks](https://reader035.vdocument.in/reader035/viewer/2022081604/62c1cb600813c7640b7f2414/html5/thumbnails/21.jpg)
Aplicaciones:
Object Detection
Segmentation
Filtering
Super-resolution
Style transfer
Todas usan redes convolucionales !
![Page 22: Deep Learning: The Third Wave the Neural Networks](https://reader035.vdocument.in/reader035/viewer/2022081604/62c1cb600813c7640b7f2414/html5/thumbnails/22.jpg)
Objetivo de hoy
Base de datos MNIST: 70,000 imágenes (de tamaño 28 x 28). (de ellos, 60,000 son de entrenamiento y 10,000 son de prueba).
Vamos a implementar una red convolucional que aprendan a clasificar los dígitos de MNIST.