SlideShare a Scribd company logo
By,
Anaswara K U
S-7
Integrated MSc CS(AI and ML)
1. Features
2. Keras layers
3. Components
4. Advantages and
Disadvantages
What is Deep Learning Framework?
Deep learning frameworks are software libraries or tools that provide building blocks,
abstraction, and functionalities for designing training and deploying model, this frameworks
simplify the processes of implementing complex mathematics operations required for neural
networks providing it structured environment for developing algorithm.
They simplify AI development by offering pre-built components and APIs, enabling developers to
focus on designing and training models.
Python Keras module for advanced python programming
What is Keras?
Keras is a popular high-level deep learning API written in
Python that runs on top of lower-level deep learning
frameworks like TensorFlow. It provides a user-friendly,
modular interface for building and training neural networks.
High-level API(frontend) & Low-level API(backend)
A high level API provides simplified user
friendly way to perform tasks without
requiring knowledge of the complex,
underlying details. It abstracts away
much of the complexity, allowing you to
focus on your main goals, such as
building and training machine learning
models.
A low-level API provides exposes the
core components and functions that
interact directly with the system or
perform the underlying computations.
This type of API requires more detailed
knowledge of the inner workings but
offers much more flexibility and control.
Features of keras
● Simple – but not simplistic. Keras reduces developer cognitive load to free you to
focus on the parts of the problem that really matter.
● Flexible – Keras adopts the principle of progressive disclosure of complexity:
simple workflows should be quick and easy, while arbitrarily advanced workflows
should be possible via a clear path that builds upon what you've already learned.
● Powerful – Keras provides industry-strength performance and scalability: it is
used by organizations including NASA, YouTube, or Waymo.
Features of keras
● Keras prioritises developer experience.
● Keras is broadly adopted in the industry and among the research community.
● Keras models are easy to turn models into products.
● Support multiple backend engines and does not lock you into one ecosystem.
● Keras has strong multi GPU support and distributed training support.
Types of keras models
Sequential Model
● The Sequential model is the simplest type of
model in Keras. It allows you to build a
neural network by stacking layers on top of
each other in a linear (sequential) fashion.
Functional API
● The Functional API in Keras provides a
more flexible way to build models.
● It allows for defining complex architectures,
including models with multiple inputs and
outputs, shared layers, and non-linear data
flows (such as residual connections or
multi-branch networks).
Example: keras sequential
import keras
from keras import layers
model = keras.Sequential()
model.add(layers.Dense(2, activation="relu"))
model.add(layers.Dense(3, activation="relu"))
model.add(layers.Dense(4
Example: Keras Functional API
from keras.models import Model
from keras.layers import Input
from keras.layers import Dense
visible = Input(shape=(2,))
hidden = Dense(2)(visible)
model = Model(inputs=visible, outputs=hidden)
Model subclassing, where you implement everything from scratch on your own. Use this if you have
complex, out-of-the-box research use cases.
Keras Layers
Layers are the basic building blocks of neural networks in Keras. A
layer consists of a tensor-in tensor-out computation function (the
layer's call method) and some state, held in TensorFlow variables (the
layer's weights).
1. Core Layers:
○ Input Layer: Defines the input shape of the neural network.
○ Dense Layer: Fully connected layer, where each neuron is connected to every neuron in the previous layer
○ Activation Layers: Apply activation functions to introduce non-linearity.
○ Dropout Layer: Prevents overfitting by randomly setting a fraction of input units to zero.
○ Flatten Layer: Reshapes multi-dimensional input into a one-dimensional vector.
○ Reshape Layer: Reshapes the input tensor to a specified shape.
○ Permute Layer: Rearranges the dimensions of an input tensor.
○ RepeatVector Layer: Repeats the input along a new axis.
○ Lambda Layer: Applies an arbitrary function to the input.Masking Layer: Marks specific values in the input as
"masked" (ignored).
○ Embedding Layer: Converts categorical data into dense vectors.
2. Convolution Layers
● Conv1D, Conv2D, Conv3D: Perform convolution operations on 1D, 2D, or 3D input data.
● Useful for tasks such as image classification, video analysis, and time series prediction.
● Conv2DTranspose, Conv3DTranspose: Perform transposed convolutions, often used in
generative models and image segmentation.
● SeparableConv2D, DepthwiseConv2D: Efficient convolutions by splitting the convolution
operation into multiple parts, reducing computation costs.
3. Pooling Layers:
● MaxPooling2D: Downsamples input images by taking the maximum value in each pooling region.
● MaxPooling3D: Downsamples volumetric data by taking the maximum value in each pooling region.
● AveragePooling2D: Downsamples input images by taking the average value in each pooling region.
● AveragePooling3D: Downsamples volumetric data by taking the average value in each pooling region.
● GlobalMaxPooling2D: Downsamples input images to a single value by taking the maximum value across all spatial
dimensions
● GlobalMaxPooling3D: Downsamples volumetric data to a single value by taking the maximum value across all spatial
dimensions.
● GlobalAveragePooling2D: Downsamples input images to a single value by taking the average value across all spatial
dimensions.
● GlobalAveragePooling3D: Downsamples volumetric data to a single value by taking the average value across all
spatial dimensions.
1. Modularity
Keras is modular. It considers a model in the form of a graph or a sequence. Keras allows you to save the
model you are working on. Keras provides a save() method to save the current model. You can even use
the model in the future.
2. Large Dataset
Keras contains a large pre-defined dataset. It provides you a variety of datasets. You can use this dataset
to be directly importing and loading it.
3. Train from NumPy Data
Keras uses the NumPy array to train and evaluate the model. It makes use of the fit() method.
The fit() method fits the model to the training data. This training process may take some time.
fit() method had three arguments batch_size, validation_data and epochs.
4. Evaluation and Prediction
Keras has evaluate() and predict() methods. These methods can use the dataset of NumPy.
After testing the data, the evaluation of the result is done. These methods are used to evaluate
our models.
5. Pre-trained Models in Keras
Keras contains a number of pre-trained models. These models can be imported from keras.applications.
These models are useful for feature extraction and fine-tuning. Keras.application is a module that contains
weights for image classification like VGG16, VGG19, Xception, etc.
6. Encoding in Keras
Karas allows you encoding feature. There is one_hot() function in Keras that enables encoding. It helps
you to encode integers in one step. It also enables you to tokenize the data. This function filters out the
white spaces, make the text to lower case, and filter out the punctuations.
7. Layers in Keras
There are numerous layers and parameters in Keras. All Keras layers have a number of methods in them.
These layers are useful to construct, train, configure the data. The dense layer is beneficial to implement
operations.
What is keras layers?
Keras layers are the building blocks used in designing and implementing
neural networks. These layers analyze the structure of input data, perform
transformations like convolution, pooling, and dense connections, and are
combined to create neural network architectures for various machine
learning tasks. Keras provides a wide variety of standard layers to handle
different types of input data and neural network architectures.
Types of Keras Layers
1. Convolutional Layers
This layer is mainly used in case of Image processing or Video processing
tasks for spatial convolution over images or sequences. The functionality of
the convolution layer is to apply the specified filters for input image to
generate feature maps.
Types of Keras layers
2. Pooling Layers
Pooling layer is used to reduce the dimensions of the feature map from the previous layer
before passing it to next layer in-order to make the computation faster and prevent overfitting.
Two main types of pooling layer are max pooling layer and average pooling layer.
● Max pooling layer takes the maximum of the input region. If we consider a 2×2 matrix
it is replaced by single value which is maximum among the four values.
● Similarly Average pooling layer takes the average of all the input values. If we
consider a 2×2 matrix it is replaced by a single value which is average of all the four
values.
Types of Keras layers
3. Dense Layer
● A fully connected neural network layer.
● Each neuron in the layer is connected to every neuron in the previous layer.
● Used for both input and output layers.
● Often used in the final layers of a network to make predictions.
keras.layers.Dense(units, activation=None, ...)
● units: Number of neurons in the layer.
● activation: Activation function (e.g., 'relu', 'sigmoid', 'softmax').
Types of Keras layers
4. Flatten Layer:
● Converts a multi-dimensional input (e.g., from a convolutional layer) into a 1D array.
● Useful when transitioning from convolutional layers to dense layers.
● The primary purpose of the Flatten layer is to transform the output of previous layers (like convolutional
layers) into a format that is compatible with the dense layers that follow.
● For example, convolutional layers output a 3D tensor (height, width, and number of channels), but a dense
layer requires a 1D vector as input. The Flatten layer reshapes the multi-dimensional data into a single long
vector.
● Although the Flatten layer does not perform any learning or modification of weights, it preserves the order of
the features while converting the multi-dimensional data into a 1D array. This allows the model to maintain
the spatial and hierarchical information extracted by previous layers.
keras.layers.Flatten()
Types of Keras layers
5. Dropout Layer:
● A regularization technique that randomly sets a fraction of input units to zero
at each update during training.
● Helps prevent overfitting by ensuring the network does not rely too heavily
on any one feature.
keras.layers.Dropout(rate)
rate: Fraction of the input units to drop (e.g., 0.5 means 50% of inputs will be set to zero).
Types of Keras layers
6. Activation Layer:
● Applies an activation function to the input.
● Can be a separate layer, but often specified directly within other layers (like Dense).
● keras.layers.Activation(activation)
● activation: The activation function to apply (e.g., 'relu', 'tanh', 'sigmoid').
Python Keras module for advanced python programming
Advantages of Keras
● User-friendly:
○ Keras has a simple, intuitive API that makes it easy to build and train deep learning models.
○ It abstracts away many of the complexities of TensorFlow, making it a good choice for
beginners.
● Fast Prototyping:
○ Keras allows for quick experimentation and iteration.
○ You can build complex models with just a few lines of code. Multiple
● Backend Support:
○ Keras can run on top of different backend engines like TensorFlow, Theano, and CNTK.
○ This provides flexibility and allows you to choose the backend that best suits your needs.
● Wide Adoption:
○ Keras is widely adopted by the community and industry, which means there are
abundant resources, tutorials, and support available.
● Model Deployment:
○ Keras models can be easily deployed to various platforms, including web browsers,
mobile devices, and embedded systems.
● Less Flexibility: While Keras' simplicity is a strength, it can also be a limitation. For
advanced users, the high-level abstractions might hide some of the lower-level details,
making it challenging to customize or implement certain complex operations.
● Performance Overhead: For very large and complex models, the abstraction layer in Keras
can introduce some performance overhead compared to using TensorFlow directly.
● Debugging: While Keras' error messages have improved, they can sometimes be less
informative compared to TensorFlow. This can make debugging more challenging in certain
cases.
● Limited Features: Compared to TensorFlow, Keras may have fewer advanced features and
functionalities, especially for research-oriented tasks.
Disadvantages of Keras
Thank You

More Related Content

Similar to Python Keras module for advanced python programming (20)

PPTX
Keras: A versatile modeling layer for deep learning
Dr. Ananth Krishnamoorthy
 
PDF
First steps with Keras 2: A tutorial with Examples
Felipe
 
PDF
keras_tutorial.pdf
Lê Duy Tân
 
PDF
TensorFlow meetup: Keras - Pytorch - TensorFlow.js
Stijn Decubber
 
PPTX
python_libraries_for_artificial_intelligence.pptx
salehaalsaleh602
 
PPTX
Machine Learning Toolssssssssssssss.pptx
salehaalsaleh602
 
PDF
dfdshofdifhdifhdfhgfoighfgofgfgfgfgdfdfdfdf
nguyenhoangy207
 
PPTX
Demystifying-AI-Frameworks-TensorFlow-PyTorch-JAX-and-More (1).pptx
Anant Garg
 
PDF
1645 goldenberg using our laptop
Rising Media, Inc.
 
PDF
Transfer Learning
Hichem Felouat
 
PPTX
Keras_Core_introduction.pptx
GDSCBBIT
 
PDF
Keras and TensorFlow
NopphawanTamkuan
 
PDF
Getting Started with Keras and TensorFlow - StampedeCon AI Summit 2017
StampedeCon
 
PDF
unit-iii-deep-learningunit-iii-deep-learning.pdf
nandan543979
 
PPTX
Automatic Attendace using convolutional neural network Face Recognition
vatsal199567
 
PDF
dl-unit-3 materialdl-unit-3 material.pdf
nandan543979
 
PPTX
Deep Learning, Keras, and TensorFlow
Oswald Campesato
 
PPTX
Keras on tensorflow in R & Python
Longhow Lam
 
PDF
Keras cheat sheet_python
Coding Tonic
 
Keras: A versatile modeling layer for deep learning
Dr. Ananth Krishnamoorthy
 
First steps with Keras 2: A tutorial with Examples
Felipe
 
keras_tutorial.pdf
Lê Duy Tân
 
TensorFlow meetup: Keras - Pytorch - TensorFlow.js
Stijn Decubber
 
python_libraries_for_artificial_intelligence.pptx
salehaalsaleh602
 
Machine Learning Toolssssssssssssss.pptx
salehaalsaleh602
 
dfdshofdifhdifhdfhgfoighfgofgfgfgfgdfdfdfdf
nguyenhoangy207
 
Demystifying-AI-Frameworks-TensorFlow-PyTorch-JAX-and-More (1).pptx
Anant Garg
 
1645 goldenberg using our laptop
Rising Media, Inc.
 
Transfer Learning
Hichem Felouat
 
Keras_Core_introduction.pptx
GDSCBBIT
 
Keras and TensorFlow
NopphawanTamkuan
 
Getting Started with Keras and TensorFlow - StampedeCon AI Summit 2017
StampedeCon
 
unit-iii-deep-learningunit-iii-deep-learning.pdf
nandan543979
 
Automatic Attendace using convolutional neural network Face Recognition
vatsal199567
 
dl-unit-3 materialdl-unit-3 material.pdf
nandan543979
 
Deep Learning, Keras, and TensorFlow
Oswald Campesato
 
Keras on tensorflow in R & Python
Longhow Lam
 
Keras cheat sheet_python
Coding Tonic
 

Recently uploaded (20)

PPTX
Daily, Weekly, Monthly Report MTC March 2025.pptx
PanjiDewaPamungkas1
 
PPTX
Monitoring Improvement ( Pomalaa Branch).pptx
fajarkunee
 
PPTX
Presentation.pptx hhgihyugyygyijguuffddfffffff
abhiruppal2007
 
PDF
5- Global Demography Concepts _ Population Pyramids .pdf
pkhadka824
 
PDF
TESDA License NC II PC Operations TESDA, Office Productivity
MELJUN CORTES
 
PDF
Microsoft Power BI - Advanced Certificate for Business Intelligence using Pow...
Prasenjit Debnath
 
PDF
GOOGLE ADS (1).pdf THE ULTIMATE GUIDE TO
kushalkeshwanisou
 
PDF
NVIDIA Triton Inference Server, a game-changing platform for deploying AI mod...
Tamanna36
 
PDF
Informatics Market Insights AI Workforce.pdf
karizaroxx
 
DOCX
COT Feb 19, 2025 DLLgvbbnnjjjjjj_Digestive System and its Functions_PISA_CBA....
kayemorales1105
 
PDF
Kafka Use Cases Real-World Applications
Accentfuture
 
PPTX
MENU-DRIVEN PROGRAM ON ARUNACHAL PRADESH.pptx
manvi200807
 
PPTX
Project_Update_Summary.for the use from PM
Odysseas Lekatsas
 
PPTX
english9quizw1-240228142338-e9bcf6fd.pptx
rossanthonytan130
 
PDF
Data science AI/Ml basics to learn .pdf
deokhushi04
 
PPTX
727325165-Unit-1-Data-Analytics-PPT-1.pptx
revathi148366
 
PDF
SaleServicereport and SaleServicereport
2251330007
 
DOCX
brigada_PROGRAM_25.docx the boys white house
RonelNebrao
 
PDF
A Web Repository System for Data Mining in Drug Discovery
IJDKP
 
PPTX
Generative AI Boost Data Governance and Quality- Tejasvi Addagada
Tejasvi Addagada
 
Daily, Weekly, Monthly Report MTC March 2025.pptx
PanjiDewaPamungkas1
 
Monitoring Improvement ( Pomalaa Branch).pptx
fajarkunee
 
Presentation.pptx hhgihyugyygyijguuffddfffffff
abhiruppal2007
 
5- Global Demography Concepts _ Population Pyramids .pdf
pkhadka824
 
TESDA License NC II PC Operations TESDA, Office Productivity
MELJUN CORTES
 
Microsoft Power BI - Advanced Certificate for Business Intelligence using Pow...
Prasenjit Debnath
 
GOOGLE ADS (1).pdf THE ULTIMATE GUIDE TO
kushalkeshwanisou
 
NVIDIA Triton Inference Server, a game-changing platform for deploying AI mod...
Tamanna36
 
Informatics Market Insights AI Workforce.pdf
karizaroxx
 
COT Feb 19, 2025 DLLgvbbnnjjjjjj_Digestive System and its Functions_PISA_CBA....
kayemorales1105
 
Kafka Use Cases Real-World Applications
Accentfuture
 
MENU-DRIVEN PROGRAM ON ARUNACHAL PRADESH.pptx
manvi200807
 
Project_Update_Summary.for the use from PM
Odysseas Lekatsas
 
english9quizw1-240228142338-e9bcf6fd.pptx
rossanthonytan130
 
Data science AI/Ml basics to learn .pdf
deokhushi04
 
727325165-Unit-1-Data-Analytics-PPT-1.pptx
revathi148366
 
SaleServicereport and SaleServicereport
2251330007
 
brigada_PROGRAM_25.docx the boys white house
RonelNebrao
 
A Web Repository System for Data Mining in Drug Discovery
IJDKP
 
Generative AI Boost Data Governance and Quality- Tejasvi Addagada
Tejasvi Addagada
 
Ad

Python Keras module for advanced python programming

  • 2. 1. Features 2. Keras layers 3. Components 4. Advantages and Disadvantages
  • 3. What is Deep Learning Framework? Deep learning frameworks are software libraries or tools that provide building blocks, abstraction, and functionalities for designing training and deploying model, this frameworks simplify the processes of implementing complex mathematics operations required for neural networks providing it structured environment for developing algorithm. They simplify AI development by offering pre-built components and APIs, enabling developers to focus on designing and training models.
  • 5. What is Keras? Keras is a popular high-level deep learning API written in Python that runs on top of lower-level deep learning frameworks like TensorFlow. It provides a user-friendly, modular interface for building and training neural networks.
  • 6. High-level API(frontend) & Low-level API(backend) A high level API provides simplified user friendly way to perform tasks without requiring knowledge of the complex, underlying details. It abstracts away much of the complexity, allowing you to focus on your main goals, such as building and training machine learning models. A low-level API provides exposes the core components and functions that interact directly with the system or perform the underlying computations. This type of API requires more detailed knowledge of the inner workings but offers much more flexibility and control.
  • 7. Features of keras ● Simple – but not simplistic. Keras reduces developer cognitive load to free you to focus on the parts of the problem that really matter. ● Flexible – Keras adopts the principle of progressive disclosure of complexity: simple workflows should be quick and easy, while arbitrarily advanced workflows should be possible via a clear path that builds upon what you've already learned. ● Powerful – Keras provides industry-strength performance and scalability: it is used by organizations including NASA, YouTube, or Waymo.
  • 8. Features of keras ● Keras prioritises developer experience. ● Keras is broadly adopted in the industry and among the research community. ● Keras models are easy to turn models into products. ● Support multiple backend engines and does not lock you into one ecosystem. ● Keras has strong multi GPU support and distributed training support.
  • 9. Types of keras models Sequential Model ● The Sequential model is the simplest type of model in Keras. It allows you to build a neural network by stacking layers on top of each other in a linear (sequential) fashion. Functional API ● The Functional API in Keras provides a more flexible way to build models. ● It allows for defining complex architectures, including models with multiple inputs and outputs, shared layers, and non-linear data flows (such as residual connections or multi-branch networks).
  • 10. Example: keras sequential import keras from keras import layers model = keras.Sequential() model.add(layers.Dense(2, activation="relu")) model.add(layers.Dense(3, activation="relu")) model.add(layers.Dense(4
  • 11. Example: Keras Functional API from keras.models import Model from keras.layers import Input from keras.layers import Dense visible = Input(shape=(2,)) hidden = Dense(2)(visible) model = Model(inputs=visible, outputs=hidden)
  • 12. Model subclassing, where you implement everything from scratch on your own. Use this if you have complex, out-of-the-box research use cases.
  • 13. Keras Layers Layers are the basic building blocks of neural networks in Keras. A layer consists of a tensor-in tensor-out computation function (the layer's call method) and some state, held in TensorFlow variables (the layer's weights).
  • 14. 1. Core Layers: ○ Input Layer: Defines the input shape of the neural network. ○ Dense Layer: Fully connected layer, where each neuron is connected to every neuron in the previous layer ○ Activation Layers: Apply activation functions to introduce non-linearity. ○ Dropout Layer: Prevents overfitting by randomly setting a fraction of input units to zero. ○ Flatten Layer: Reshapes multi-dimensional input into a one-dimensional vector. ○ Reshape Layer: Reshapes the input tensor to a specified shape. ○ Permute Layer: Rearranges the dimensions of an input tensor. ○ RepeatVector Layer: Repeats the input along a new axis. ○ Lambda Layer: Applies an arbitrary function to the input.Masking Layer: Marks specific values in the input as "masked" (ignored). ○ Embedding Layer: Converts categorical data into dense vectors.
  • 15. 2. Convolution Layers ● Conv1D, Conv2D, Conv3D: Perform convolution operations on 1D, 2D, or 3D input data. ● Useful for tasks such as image classification, video analysis, and time series prediction. ● Conv2DTranspose, Conv3DTranspose: Perform transposed convolutions, often used in generative models and image segmentation. ● SeparableConv2D, DepthwiseConv2D: Efficient convolutions by splitting the convolution operation into multiple parts, reducing computation costs.
  • 16. 3. Pooling Layers: ● MaxPooling2D: Downsamples input images by taking the maximum value in each pooling region. ● MaxPooling3D: Downsamples volumetric data by taking the maximum value in each pooling region. ● AveragePooling2D: Downsamples input images by taking the average value in each pooling region. ● AveragePooling3D: Downsamples volumetric data by taking the average value in each pooling region. ● GlobalMaxPooling2D: Downsamples input images to a single value by taking the maximum value across all spatial dimensions ● GlobalMaxPooling3D: Downsamples volumetric data to a single value by taking the maximum value across all spatial dimensions. ● GlobalAveragePooling2D: Downsamples input images to a single value by taking the average value across all spatial dimensions. ● GlobalAveragePooling3D: Downsamples volumetric data to a single value by taking the average value across all spatial dimensions.
  • 17. 1. Modularity Keras is modular. It considers a model in the form of a graph or a sequence. Keras allows you to save the model you are working on. Keras provides a save() method to save the current model. You can even use the model in the future. 2. Large Dataset Keras contains a large pre-defined dataset. It provides you a variety of datasets. You can use this dataset to be directly importing and loading it.
  • 18. 3. Train from NumPy Data Keras uses the NumPy array to train and evaluate the model. It makes use of the fit() method. The fit() method fits the model to the training data. This training process may take some time. fit() method had three arguments batch_size, validation_data and epochs. 4. Evaluation and Prediction Keras has evaluate() and predict() methods. These methods can use the dataset of NumPy. After testing the data, the evaluation of the result is done. These methods are used to evaluate our models.
  • 19. 5. Pre-trained Models in Keras Keras contains a number of pre-trained models. These models can be imported from keras.applications. These models are useful for feature extraction and fine-tuning. Keras.application is a module that contains weights for image classification like VGG16, VGG19, Xception, etc. 6. Encoding in Keras Karas allows you encoding feature. There is one_hot() function in Keras that enables encoding. It helps you to encode integers in one step. It also enables you to tokenize the data. This function filters out the white spaces, make the text to lower case, and filter out the punctuations. 7. Layers in Keras There are numerous layers and parameters in Keras. All Keras layers have a number of methods in them. These layers are useful to construct, train, configure the data. The dense layer is beneficial to implement operations.
  • 20. What is keras layers? Keras layers are the building blocks used in designing and implementing neural networks. These layers analyze the structure of input data, perform transformations like convolution, pooling, and dense connections, and are combined to create neural network architectures for various machine learning tasks. Keras provides a wide variety of standard layers to handle different types of input data and neural network architectures.
  • 21. Types of Keras Layers 1. Convolutional Layers This layer is mainly used in case of Image processing or Video processing tasks for spatial convolution over images or sequences. The functionality of the convolution layer is to apply the specified filters for input image to generate feature maps.
  • 22. Types of Keras layers 2. Pooling Layers Pooling layer is used to reduce the dimensions of the feature map from the previous layer before passing it to next layer in-order to make the computation faster and prevent overfitting. Two main types of pooling layer are max pooling layer and average pooling layer. ● Max pooling layer takes the maximum of the input region. If we consider a 2×2 matrix it is replaced by single value which is maximum among the four values. ● Similarly Average pooling layer takes the average of all the input values. If we consider a 2×2 matrix it is replaced by a single value which is average of all the four values.
  • 23. Types of Keras layers 3. Dense Layer ● A fully connected neural network layer. ● Each neuron in the layer is connected to every neuron in the previous layer. ● Used for both input and output layers. ● Often used in the final layers of a network to make predictions. keras.layers.Dense(units, activation=None, ...) ● units: Number of neurons in the layer. ● activation: Activation function (e.g., 'relu', 'sigmoid', 'softmax').
  • 24. Types of Keras layers 4. Flatten Layer: ● Converts a multi-dimensional input (e.g., from a convolutional layer) into a 1D array. ● Useful when transitioning from convolutional layers to dense layers. ● The primary purpose of the Flatten layer is to transform the output of previous layers (like convolutional layers) into a format that is compatible with the dense layers that follow. ● For example, convolutional layers output a 3D tensor (height, width, and number of channels), but a dense layer requires a 1D vector as input. The Flatten layer reshapes the multi-dimensional data into a single long vector. ● Although the Flatten layer does not perform any learning or modification of weights, it preserves the order of the features while converting the multi-dimensional data into a 1D array. This allows the model to maintain the spatial and hierarchical information extracted by previous layers. keras.layers.Flatten()
  • 25. Types of Keras layers 5. Dropout Layer: ● A regularization technique that randomly sets a fraction of input units to zero at each update during training. ● Helps prevent overfitting by ensuring the network does not rely too heavily on any one feature. keras.layers.Dropout(rate) rate: Fraction of the input units to drop (e.g., 0.5 means 50% of inputs will be set to zero).
  • 26. Types of Keras layers 6. Activation Layer: ● Applies an activation function to the input. ● Can be a separate layer, but often specified directly within other layers (like Dense). ● keras.layers.Activation(activation) ● activation: The activation function to apply (e.g., 'relu', 'tanh', 'sigmoid').
  • 28. Advantages of Keras ● User-friendly: ○ Keras has a simple, intuitive API that makes it easy to build and train deep learning models. ○ It abstracts away many of the complexities of TensorFlow, making it a good choice for beginners. ● Fast Prototyping: ○ Keras allows for quick experimentation and iteration. ○ You can build complex models with just a few lines of code. Multiple ● Backend Support: ○ Keras can run on top of different backend engines like TensorFlow, Theano, and CNTK. ○ This provides flexibility and allows you to choose the backend that best suits your needs.
  • 29. ● Wide Adoption: ○ Keras is widely adopted by the community and industry, which means there are abundant resources, tutorials, and support available. ● Model Deployment: ○ Keras models can be easily deployed to various platforms, including web browsers, mobile devices, and embedded systems.
  • 30. ● Less Flexibility: While Keras' simplicity is a strength, it can also be a limitation. For advanced users, the high-level abstractions might hide some of the lower-level details, making it challenging to customize or implement certain complex operations. ● Performance Overhead: For very large and complex models, the abstraction layer in Keras can introduce some performance overhead compared to using TensorFlow directly. ● Debugging: While Keras' error messages have improved, they can sometimes be less informative compared to TensorFlow. This can make debugging more challenging in certain cases. ● Limited Features: Compared to TensorFlow, Keras may have fewer advanced features and functionalities, especially for research-oriented tasks. Disadvantages of Keras