MLT Unit 1 & 2
MLT Unit 1 & 2
LEARNING WITH
TENSORFLOW
Tensorsflow
• 3. Easily Trainable
• It is easily trainable on CPU and for GPU in
distributed computing.
4. Parallel Neural Network Training
• TensorFlow offers to the pipeline in the sense that we
can train multiple neural networks and various GPUs,
which makes the models very efficient on large-scale
systems.
5. Large Community
• Google has developed it, and there already is a large
team of software engineers who work on stability
improvements continuously.
6. Open Source
• The best thing about the machine learning library is
that it is open source so anyone can use it as much as
they have internet connectivity.
7. Feature Columns -
• TensorFlow has feature columns which could be
thought of as intermediates between raw data and
estimators; accordingly, bridging input data with our
model.
8. Availability of Statistical Distributions
• This library provides distributions functions including
Bernoulli, Beta, Chi2, Uniform, Gamma, which are
essential, especially where considering probabilistic
approaches such as Bayesian models.
• 9. Layered Components
• TensorFlow produces layered operations of weight
and biases from the function such as tf.contrib.layers
and also provides batch normalization, convolution
layer, and dropout layer.
• So tf.contrib.layers.optimizers have optimizers such
as Adagrad, SGD, Momentum which are often used
to solve optimization problems for numerical analysis.
• 10. Visualizer (With TensorBoard)
• We can inspect a different representation of a model
and make the changed necessary while debugging it
with the help of TensorBoard.
Figure: Here are images of three objects: a lamp, a pair of pants, and a dog.
What are some good features that you should record to compare and
differentiate objects?
Figure 1.9 Feature vectors are a representation of real world data used by both the
learning and inference components of machine learning. The input to the
algorithm is not the real-world image directly, but instead its feature vector.
Representation of a Tensor
• tf.Variable
• tf.constant - Creates a constant tensor from a tensor-
like object.
• tf.placeholder
• tf.SparseTensor
Creating tensors
OUTPUT
• As you can see from the output, each tensor is represented by
the aptly named Tensor object.
• Each Tensor object has a unique label (name), a dimension
(shape) to define its structure, and data type (dtype) to specify
the kind of values we will manipulate. Because we did not
explicitly provide a name, the library automatically generated
the names: “Const:0”, “Const_1:0”, and “Const_2:0”.
for example
Creating Operator
• https://www.javatpoint.com/tensorflow-
playground
Tensorflow Playground
• https://blog.tensorflow.org/2019/01/whats-coming-in-
tensorflow-2-0.html
TensorFlow 2.0 Architecture
TensorFlow 2.0. TensorFlow 2.0 will focus on
simplicity and ease of use, featuring updates like:
• Easy model building with Keras and eager execution.
• Robust model deployment in production on any
platform.
• Powerful experimentation for research.
• Simplifying the API by cleaning up deprecated APIs
and reducing duplication.
TensorFlow 2.0 Architecture
Load your data using tf.data -
• Hidden Layers: These are the intermediate layers between the input and output
layers. Each hidden layer consists of one or more neurons (nodes) and applies
various operations on the data. Common types of hidden layers include Dense (fully
connected), Convolutional, Recurrent, etc., depending on the type of model being
built.
• Output Layer: This is the final layer of the model and produces the output predictions.
The number of neurons in this layer corresponds to the number of output classes or
the desired output dimensions.
• The arrows in the diagram represent the
flow of information from one layer to
another, with each layer's output serving
as the input to the next layer
KERAS APPLICATION
• Keras applications module is used to provide pre-trained model for
deep neural networks. Keras models are used for prediction, feature
extraction and fine tuning. This chapter explains about Keras
applications in detail.
• Pre-trained models
• Trained model consists of two parts model Architecture and model
Weights. Model weights are large file so we have to download and
extract the feature from ImageNet database. Some of the popular
pre-trained models are listed below,
• ResNet
• VGG16
• MobileNet
• InceptionResNetV2
• InceptionV3
UNIT --2
EXPLORING THE DATA WITH
TENSORFLOW FRAMEWORK
What is a Binary Classifier in Machine Learning?
Y=f(∑wi*xi + b)
Advantages of SLP
1. Linear Separability: Single-layer perceptrons are effective at
solving linearly separable classification problems. If the
classes can be separated by a single hyperplane, a single-layer
perceptron can learn to classify them accurately. For example,
classifying points in a 2D space into two distinct classes using
a straight line.
2. Low Computational Complexity: Due to their single-layer
architecture, training and using a single-layer perceptron is
computationally efficient. This makes them suitable for tasks
where real-time or rapid decision-making is required.
3 . Simplicity and Interpretability: Single-layer perceptrons have
a straightforward structure, which makes them easy to understand
and interpret. This can be useful for educational purposes or
when a simple, transparent model is desired.
The only APIs having the official backing of TensorFlow are C and Python
API (some parts). C APIs should be used whenever we are about to make
TensorFlow API for some other languages, as lots of languages have ways to
connect with C language.
• Splits: The first version of MS COCO dataset was released in 2014. It contains
164K images split into training (83K), validation (41K) and test (41K) sets. In 2015
additional test set of 81K images was released, including all the previous test
images and 40K new images.
• Configuration:
• Define the model architecture and training parameters in
a configuration file. The configuration file specifies the
base model, anchor settings, training schedule,
augmentation options, and more.
• Model Training:
• Model Evaluation:
• After training, evaluate your model's performance on a
separate evaluation dataset using metrics like mAP
(mean average precision).
• Inference and Deployment: