Convolutional Neural Networks with Keras
![](https://s3.amazonaws.com/media-p.slid.es/uploads/752781/images/4292464/fourtheorem.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/752781/images/4292461/logowithtext.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/752781/images/4292424/republicofwork.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/752781/images/4292422/metsitaba.png)
Introducing ....
- Open Source, High-Level deep-learning library in python
- Sits on top of your normal deep-learning framework (tensorflow, theano, MXNet, CNTK etc)
Why Keras?
- Allows you to build most model architectures very quickly
- Removes the tedium of lower-level coding e.g.
- No handling of tensorflow session
- No keeping track of matrix sizes
- No management of weights and biases
![](https://s3.amazonaws.com/media-p.slid.es/uploads/752781/images/4532146/keras-logo-2018-large-1200.png)
Keelin Murphy
![](http://www.stickpng.com/assets/images/580b57fcd9996e24bc43c53e.png)
Courtesy Keelin Murphy
@MurphyKeelin
Before we dive in...
![](https://s3.amazonaws.com/media-p.slid.es/uploads/752781/images/4532158/keras_web.png)
Great documentation at keras.io
Since 2017 keras is integrated as
part of tensorflow core
![](https://s3.amazonaws.com/media-p.slid.es/uploads/752781/images/4532163/tf_web.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/752781/images/4532166/stackoverflow.png)
Large user base and good online support
Keelin Murphy
![](http://www.stickpng.com/assets/images/580b57fcd9996e24bc43c53e.png)
Courtesy Keelin Murphy
@MurphyKeelin
Coding in Keras
Raw Tensorflow 2 convolutional layers
And now with Keras
![](https://s3.amazonaws.com/media-p.slid.es/uploads/752781/images/4533319/conv_layer_keras.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/752781/images/4533327/conv_layer_tf.png)
Keelin Murphy
![](http://www.stickpng.com/assets/images/580b57fcd9996e24bc43c53e.png)
Courtesy Keelin Murphy
@MurphyKeelin
Coding in Keras
Raw Tensorflow - Adding a Dense Layer
And now with Keras
![](https://s3.amazonaws.com/media-p.slid.es/uploads/752781/images/4539858/dense_tf.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/752781/images/4539870/dense_keras.png)
Keelin Murphy
![](http://www.stickpng.com/assets/images/580b57fcd9996e24bc43c53e.png)
Courtesy Keelin Murphy
@MurphyKeelin
Coding in Keras
Raw Tensorflow - Loss and Optimizer
And now with Keras
![](https://s3.amazonaws.com/media-p.slid.es/uploads/752781/images/4540082/loss_opt_tf.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/752781/images/4540099/loss_opt_keras.png)
Keelin Murphy
![](http://www.stickpng.com/assets/images/580b57fcd9996e24bc43c53e.png)
Courtesy Keelin Murphy
@MurphyKeelin
Coding in Keras
Raw Tensorflow - Training
And now with Keras
![](https://s3.amazonaws.com/media-p.slid.es/uploads/752781/images/4540160/train_tf.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/752781/images/4540175/train_keras.png)
Note on "epochs":
An epoch (in keras case) implies a run through the entire dataset (55,000 images).
In tensorflow we made 20,000 iterations over batches of size 50. This equates to 1,000,000 training samples.
In keras to use 1,000,000 training samples we will need to run through the entire dataset (1,000,000 / 55.000) times which is ~= 18 times (18 epochs)
Keelin Murphy
![](http://www.stickpng.com/assets/images/580b57fcd9996e24bc43c53e.png)
Courtesy Keelin Murphy
@MurphyKeelin
Coding in Keras
Raw Tensorflow - Testing
And now with Keras
![](https://s3.amazonaws.com/media-p.slid.es/uploads/752781/images/4540268/test_tf.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/752781/images/4540269/test_keras.png)
Keelin Murphy
![](http://www.stickpng.com/assets/images/580b57fcd9996e24bc43c53e.png)
Courtesy Keelin Murphy
@MurphyKeelin
Coding in Keras
![](https://s3.amazonaws.com/media-p.slid.es/uploads/752781/images/4542287/lines_code.png)
Equivalent code in keras
Code to build, train and print accuracy of our network
(tensorflow)
Keelin Murphy
![](http://www.stickpng.com/assets/images/580b57fcd9996e24bc43c53e.png)
Courtesy Keelin Murphy
@MurphyKeelin
Keras
By keelinm
Keras
- 882