2. Topics to cover.
1. Neural Network with Tensor Flow
a. Convolutional Neural Network.
2. Transfer Learning.
3. VGG16 Network.
4. Multi-Class classification.
a. Training on Real Estate images.
b. Predicting on Homes.com Images.
5. Implementing K-means on Homes.com images.
5. Tensor Flow.
● An open source software library provided by Google to work on neural
networks.
● Neural network can be defined as numerical computation using dataflow
graphs.
● Nodes in the graph represent mathematical operations, while the graph edges
represent the multidimensional data arrays communicated between them.
● This library is maintained and used in production for Google products.
7. Convolutional Neural Network
● Convolutional Neural Networks (CNNs/ConvNets) are designed to work with
Image inputs.
● Convolutional means taking a small patch and running a Neural network on
that patch mapping it to K outputs.
● Running this patch on image will create a new
image with width K.
Original Image
PATCH
New Image
Shared Weights
https://www.udacity.com/course/deep-learning-nanodegree-foundation--nd101
8. Convolution Neural Network Cont.
● Basic idea is to stack convnets forming a pyramid to progressively decrease
spacial dimension while increasing the depth.
Original Image Desired
Vectorhttps://www.udacity.com/course/deep-learning-nanodegree-foundation--nd101
9. Transfer Learning.
● In practice, very few people train an entire convolutional network from scratch
because it's relatively rare to have dataset of sufficient size.
● It is common to pretrain a ConvNet on a very large dataset (eg. ImageNet)
and use that ConvNet as feature extractor for task of interest.
● Major scenarios for transfer learning.
○ ConvNet as fixed feature extractor.
○ Fine-tuning the ConvNet.
○ Pretrained models.
http://cs231n.github.io/transfer-learning/
11. Multi-Class Classifier.
● This is a one-layer neural network where image vectors are taken as inputs
with known classes.
● This is done by using a softmax classifier which outputs probabilities for each
class label.
● This layer is then trained to classify generated vectors to its respective
classes, which can be used to predict classes of new vectors.
13. Implementation on real estate images.
Using Pre-trained VGG-
16 network to convert
image to vectors
14. Implementation on real estate images.
Using Pre-trained VGG-
16 network to convert
image to vectors Image vectors + class
labels are used to Train
a multiclass classifier to
classify images.
15. Implementation on real estate images.
Using Pre-trained VGG-
16 network to convert
image to vectors
Download test
images for real
estate categories
16. Implementation on real estate images.
Using Pre-trained VGG-
16 network to convert
image to vectors
Use trained classifier to
classify unknown
Homes.com image
vectors.
Class prediction
for image.
Download test
images for real
estate categories
33. Clustering Images.
● Grouping vectors based on distance between them is called Clustering.
● By Clustering we will be able to find similar images and duplicate images
grouped together.
● We applied K-means clustering to create clusters on homes.com image
vector data.
34. K means Clustering
Let’s take a sample group and divide into 2 clusters (k=2)
[(2,2),(1,2),(2,1),(4,4),(4,3),(3,4)]
35. K means Clustering
Let’s take a sample group and divide into 2 clusters (k=2)
[(2,2),(1,2),(2,1),(4,4),(4,3),(3,4)]
37. K means Clustering
● Distance from (1,2) and (2,2) with each data point
Distances :
(1,2) (2,1) : 1.41 (2,2) (2,1):1 (2,1) cluster 2
(1,2) (4,4) : 3.60 (2,2) (4,4):2.8 (4,4) cluster 2
(1,2) (4,3) : 3.16 (2,2) (4,3):2.23 (4,3) cluster 2
(1,2) (3,4) : 2.8 (2,2) (3,4):2.23 (3,4) cluster 2
38. K means Clustering
Mean of the points in clusters to
change the centers
Cluster 1: no change (only one point)
Cluster 2: mean (3.25,3) new center.
39. K means Clustering
Mean of the points in clusters to
change the centers
Cluster 1: no change (only one point)
Cluster 2: mean (3.25,3) new center.
40. K means Clustering
Distance from(1,2) and (3.25,3)
is calculated with each data point.
Distances :
(1,2) (2,1) : 1.41 (3.25,3) (2,1):2.35 (2,1) cluster 1
(1,2) (4,4) : 3.60 (3.25,3) (4,4):1.25 (4,4) cluster 2
(1,2) (4,3) : 3.16 (3.25,3) (4,3):1.019 (4,3) cluster 2
(1,2) (3,4) : 2.8 (3.25,3) (3,4):0.75 (3,4) cluster 2
(1,2) (2,2) : 1 (3.25,3) (2,2):1.6 (2,2) cluster 1
41. K means Clustering
Mean of the points in clusters to change the
centers
Cluster 1: mean (2,1.5) new center.
Cluster 2: mean (3.6,3.6) new center.
42. K means Clustering
Distance from(2,1.5) and (3.6,3.6)
is calculated with each data point.
Distances :
(2,1.5) (2,1) : 0.5 (3.6,3.6) (2,1):3.05 (2,1) cluster 1
(2,1.5) (4,4) : 3.20 (3.6,3.6) (4,4):0.56 (4,4) cluster 2
(2,1.5) (4,3) : 2.5 (3.6,3.6) (4,3):0.72 (4,3) cluster 2
(2,1.5) (3,4) : 2.69 (3.6,3.6) (3,4):0.72 (3,4) cluster 2
(2,1.5) (2,2) : 0.5 (3.6,3.6) (2,2):2.26 (2,2) cluster 1
(2,1.5) (1,2) : 1.11 (3.6,3.6) (1,2):3.05 (1,2) cluster 1
43. K means Clustering
Mean of the points in clusters
to change the centers
•Cluster 1: mean (1.6,1.6) new center.
•Cluster 2: mean (3.6,3.6) no change in mean.
44. K means Clustering
Mean of the points in clusters
to change the centers
•Cluster 1: mean (1.6,1.6) new center.
•Cluster 2: mean (3.6,3.6) no change in mean.
45. K means Clustering
Distance from (1.6,1.6) and (3.6,3.6)
is calculated with each data point.
Distances :
(1.6,1.6) à (2,1) : 0.72 (3.6,3.6) (2,1):3.05 (2,1) cluster 1
(1.6,1.6) à (4,4) : 3.39 (3.6,3.6) (4,4):0.56 (4,4) cluster 2
(1.6,1.6) à (4,3) : 2.77 (3.6,3.6) (4,3):0.72 (4,3) cluster 2
(1.6,1.6) à (3,4) : 2.77 (3.6,3.6) (3,4):0.72 (3,4) cluster 2
(1.6,1.6) à (2,2) : 0.56 (3.6,3.6) (2,2):2.26 (2,2) cluster 1
(1.6,1.6) à (1,2) : 0.72 (3.6,3.6) (1,2):3.05 (1,2) cluster 1
46. K means Clustering
Mean of the points in clusters
to change the centers
•Cluster 1: mean (1.6,1.6) no change in mean.
•Cluster 2: mean (3.6,3.6) no change in mean.
•This implies that data points are clustered.
47. K means Clustering
Mean of the points in clusters
to change the centers
•Cluster 1: mean (1.6,1.6) no change in mean.
•Cluster 2: mean (3.6,3.6) no change in mean.
•This implies that data points are clustered.
CLUSTER 1
CLUSTER 2
48. Deciding K in K-means
● We used the Elbow method to determine the optimal number of clusters for
homes.com image vectors.
https://en.wikipedia.org/wiki/Determining_the_number_of_clusters_in_a_data_set
49. Deciding K in K-means
https://en.wikipedia.org/wiki/Determining_the_number_of_clusters_in_a_data_set
100 Clusters
Error rate
dropped and
stabilized at
cluster 17
50. K-means Clustering.
● Image vectors can be grouped using K-means clustering, which uses
distances between vectors.
● Implemented on Homes.com sample Images (~9000 images) and grouped
images into 17 clusters.
The area of NN has originally been primarily inspired by the goal of modeling biological neural network.
Basic computational unit of brain is a neuron, which receives input signals from its dendrites and produce output signals along with axon.
Axon eventually branches out and connects via synapses to dendrites of other neurons.
In computational model of a neuron, the signals that travel along axon interact multiplicatively which the dendrites of the other neuron.
These weights are learnable (updateable) and controls the strength of influence of neuron on another.
These weights are trained based on difference between prediction and desired output. This error signal are back propagated to update weights to make predictions near to desire outputs.
So basically we need a architecture of neuron to construct neural network, and this architecture is provided by Tensor Flow.
The area of NN has originally been primarily inspired by the goal of modeling biological neural network.
Basic computational unit of brain is a neuron, which receives input signals from its dendrites and produce output signals along with axon.
Axon eventually branches out and connects via synapses to dendrites of other neurons.
In computational model of a neuron, the signals that travel along axon interact multiplicatively which the dendrites of the other neuron.
These weights are learnable (updateable) and controls the strength of influence of neuron on another.
These weights are trained based on difference between prediction and desired output. This error signal are back propagated to update weights to make predictions near to desire outputs.
So basically we need a architecture of neuron to construct neural network, and this architecture is provided by Tensor Flow.
VGG-16 is a 16 layer deep network designed by Oxford University for ImageNet Large Scale Visual Recognition Challenge and secured first and second places for localization and classification tasks respectively in 2014.
ImageNet consists of 1.2 million images with 1000 categories.