03 Convolution Neural Networks and Computer Vision With Tensorflow
03 Convolution Neural Networks and Computer Vision With Tensorflow
👩🍳 👩🔬
(w e’ ll be co ok ing u p lots of co d e! )
How:
fi
fi
fi
Computer vision inputs and outputs
224
224
[[0.31, 0.62, 0.44…], 🍣 🥩 🍕
224 [0.92, 0.03, 0.27…], [0.00, 0.97, 0.03]
[0.25, 0.78, 0.07…], i o n p r ob ab i l i t i e s )
(predict
…,
1. Turn all data into numbers (neural networks can’t handle images)
2. Make sure all of your tensors are the right shape
3. Scale features (normalize or standardize, neural networks tend to prefer normalization)
“What is a convolutional neural
network (CNN)?”
(typical)*
Architecture of a CNN
Steak 🥩
Pizza 🍕
*Note: there are almost an unlimited amount of ways you could stack together a convolutional neural network, this slide demonstrates only one.
Let’s code!
Architecture of a CNN
(col o ur e d b l o c k e d it i o n )
Simple CNN
Deeper CNN
Breakdown of Conv2D layer
Example code: tf.keras.layers.Conv2D(filters=10, kernel_size=(3, 3), strides=(1, 1), padding=“same”)
Example 2 (same as above): tf.keras.layers.Conv2D(filters=10, kernel_size=3, strides=1, padding=“same”)
Determines the shape of the lters (sliding 3, 5, 7 (lowers values learn smaller features,
Kernel size (also called lter size) higher values learn larger features)
windows) over the output.
📖 Resource: For an interactive demonstration of the above hyperparameters, see the CNN explainer website.
fi
fi
fi
fi
fi
What is overfitting?
Over tting — when a model over learns patterns in a particular dataset and isn’t able to
generalise to unseen data.
For example, a student who studies the course materials too hard and then isn’t able to perform
well on the nal exam. Or tries to put their knowledge into practice at the workplace and nds
what they learned has nothing to do with the real world.
Smaller model
Not all data samples are created equally. Removing poor samples
Better data from or adding better samples to your dataset can improve your
model’s performance.
*Note: There are many more di erent kinds of data augmentation such as, cropping, replacing, shearing. This slide only demonstrates a few.
ff
ff
Popular & useful computer vision
architectures
Release Use in
Architecture Paper When to use
Date TensorFlow
Training
Predictions
The machine learning practitioner’s
motto
👩🍳 👩🔬
(try lots of things an
d see what
tastes good)