Day 1 S2
Day 1 S2
Kavita Jain
Roadmap
•Basics of Tensorflow
•Types of tensors
•Hands-on
•Basics of Keras
•Hands-on
Deep learning packages
• TensorFlow – Google
• PyTorch – Facebook AI research
• Keras – Francois Chollet (now at Google)
•Chainer – Company in Japan
• Caffe - Berkeley Vision and Learning Center
• CNTK - Microsoft
TensorFlow
Python,C++,Java,GO
A tensor is a multi-way extension of a matrix
– A multi-dimensional array
Types of Tensors
2.Shape (shape)
Output y
c c … c
Hidden Layer 3
1 2 F
b b … b
Hidden Layer 2
1 2 E
a a … a
Hidden Layer 1
1 2 D
x x x … x
Input
1 2 3 M
Neural Network Architectures
Even for a basic Neural Network, there are many design decisions to make:
1. No. of hidden layers (depth)
2. No. of units per hidden layer (width)
3. Type of activation function (nonlinearity)
4. Form of objective function
Implementing a neural network in Keras
•CSV data needs to be parsed, with numerical features converted to floating point tensors
and categorical features converted to integer tensors.
•Images need to be read and decoded into integer tensors, then converted to floating
point and normalized to small values (usually between 0 and 1).
•Text files need to be read into string tensors, then split into words. Finally, the words
need to be indexed & turned into integer tensors.
Data loading
Keras models accept three types of inputs:
•NumPy arrays
•TensorFlow dataset objects
•Python generators
Three model building styles
29
Sequential models
model = tf.keras.models.Sequential([
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(512, activation='relu'),
tf.keras.layers.Dense(10, activation='softmax')
])
model.compile(optimizer='adam',
loss='sparse_categorical_crossentropy',
metrics=['accuracy'])
● tensorflow.org/beta
Books
For details
● deeplearningbook.org
100
Latest tutorials and guides
tensorflow.org/beta