EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 360+ Courses All in One Bundle
  • Login
Home Data Science Data Science Tutorials Keras Tutorial Keras Pre-trained Models
Secondary Sidebar
Keras Tutorial
  • Basic
    • What is Keras?
    • Keras Install
    • Keras Applications
    • Keras Sequential
    • Keras Model Predict
    • Keras Save Model
    • Keras conv2D
    • Keras ImageDataGenerator
    • Keras input
    • Keras Datasets
    • Keras Early Stopping
    • Keras input
    • Keras Model Save
    • Keras LSTM Example
    • Keras Flatten
    • Keras Optimizers
    • Keras Layers
    • Keras Dense
    • Keras fit
    • Keras Model
    • Keras Metrics
    • Keras Batch Normalization
    • Keras CNN
    • Keras predict
    • Keras Dropout
    • Keras Embedding
    • Keras LSTM
    • Keras GPU
    • Keras Tuner
    • Keras VGG16
    • Keras Generator
    • Keras Pre-trained Models
    • Keras Custom Loss Function
    • keras.utils.to_categorical
    • Keras Neural Network
    • Keras Preprocessing
    • Keras Regularization
    • Keras Softmax
    • Keras Regression
    • Keras MaxPooling2D
    • Keras U-Net
    • Keras Initializers
    • Keras Transformer
    • Keras Data Augmentation
    • Keras ResNet50
    • Keras Verbose
    • Keras Plot Model
    • Keras OCR
    • Keras Utils Sequence
    • Keras Binary Classification
    • Keras Padding
    • UpSampling2d
    • Keras EfficientNet
    • Keras pad_sequences

Keras Pre-trained Models

Keras Pre-trained Models

Introduction to Keras Pre-trained Models

Keras pre-trained models is an image classification model which was used in the python application. Keras will contain ten pre-trained models for the image classification which were trained on the data which was pretrained. Imagenet is nothing but a large collection of the data image which contains 1000 categories of images. The pretrained models can classify the image which falls into the image which contains 1000 categories.

Key Takeaways

  • The keras pre-trained model is nothing but the saved network which was trained by using a large dataset or the large-scale task classification.
  • We can use a pretrained model or we can use transfer learning for customizing the model of the specified task. The intuition behind transfer is image classification.

Overview of Keras Pre-trained Models

Basically, there are two ways to create the pretrained models in keras i.e. one is the functional API model and another is the sequential model. The sequential model contains the linear stack layer, we can simply add the layers into the sequential model by calling the method name as add. Another model is nothing but the functional API which was used to create complex models which contain multiple inputs and outputs.

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others

Tensor flow is a highly used library for machine learning, it contains keras built-in support. We can easily call the functions which were related to the keras module. The vision of computers is an interesting branch of ML. The dataset of image net is a turning point for the researchers of computer vision. Image net is nothing but the benchmark of image classification and testing accuracy for deep learning models.

Keras Pre-trained Models

There are multiple pretrained models. The vgg16 is a pre-trained model, it is trained by using imagenet. Below is the example of keras pre-trained vgg16 model as follows:

Code:

keras.applications.vgg16.VGG16 (
include_top = True,
weights = 'imagenet',
input_tensor = None,
input_shape = None,
pooling = None,
classes = 1000
)

Output:

Using imagenet

Another pre-trained model of keras is mobilenetv2. This model is trained by using imagenet. The below example shows the mobilenetv2 model as follows. In the below example, the alpha will control the network. If the value is below 1, then it will decrease the number of filters. If the value is above 1 then it will increase the number of filters in every layer.

Code:

keras.applications.mobilenet_v2.MobileNetV2 (
input_shape = None,
alpha = 2.0,
include_top = True,
weights = 'pretrained',
input_tensor = None,
pooling = None,
classes = 2000
)

Output:

Keras Pre-trained Models

Another pretrained model of keras is inceptionresnetv2. This model is trained by using imagenet. The below example shows the load of the inceptionresnetv2 model as follows. This model is built by using the data format of channels first or channels last.

Code:

keras.applications.inception_resnet_v2.InceptionResNetV2 (
include_top = True,
weights = 'pretrained',
input_tensor = None,
input_shape = None,
pooling = None,
classes = 3000)

Output:

Keras Pre-trained Models 4

Another pretrained model of keras is inceptionv3. It is trained by using imagenet. Below is the syntax of the inceptionv3 pretrained model as follows.

Code:

keras.applications.inception_v3.InceptionV3 (
include_top = True,
weights = 'pretrained',
input_tensor = None,
input_shape = None,
pooling = None,
classes = 2000)

Output:

Keras Pre-trained Models 6

Keras Pre-trained Model Functions

Below is the function of keras pretrained. Below is the function of resnet50 as follows:

Code:

tf.keras.applications.ResNet50(
include_top = True,
weights = "pretrained",
input_tensor = None,
input_shape = None,
pooling = None,
classes = 3000,
**kwargs
)

Output:

resnet50

Another function of the keras pretrained model is vgg19. The default input size of vgg19 is 299*299. Below is the example of vgg19 function model as follows.

Code:

tf.keras.applications.VGG19(
include_top = True,
weights = "pre-trained",
input_tensor = None,
input_shape = None,
pooling = None,
classes = 2000,
classifier_activation = "model",
)

Output:

Keras Pre-trained Models 8

Another function of the keras pretrained model is resnet50v2 as follows. The below example shows resnet50v2 function as follows.

Code:

tf.keras.applications.ResNet50V2(
include_top = True,
weights = "pre-trained",
input_tensor = None,
input_shape = None,
pooling = None,
classes = 2000,
classifier_activation = "model")

Output:

resnet50v2

Another function of the keras pretrained model is resnet101 as follows. The below example shows resnet101 function as follows.

Code:

tf.keras.applications.ResNet101 (
include_top = True,
weights = "pre-trained",
input_tensor = None,
input_shape = None,
pooling = None,
classes = 2000,
classifier_activation = "model")

Output:

Keras Pre-trained Models 10

Another function of the keras pretrained model is resnet152 as follows. The below example shows resnet152 function as follows.

Code:

tf.keras.applications.ResNet152 (
include_top = True,
weights = "pre-trained",
input_tensor = None,
input_shape = None,
pooling = None,
classes = 2000,
classifier_activation = "model")

Output:

Keras Pre-trained Models 11

Keras Pre-trained Model Benefits

Below are the keras pretrained model benefits as follows. Pre-trained model contains the benefits which define the keras model.

  • The keras pre-trained model will require less time for training the model, it has been trained by using the different tasks.
  • The keras model is trained by using different tasks, this model is defined by using the different tasks.
  • The keras model is used in the task by using the smaller data sets which were already defined in a larger dataset.
  • By using the keras pretrained model we can transfer the weights into the new task. The new task is created by using pretrained models.
  • In Keras’s pretrained model we can take the pre-trained model by using dataset for performing classification.
  • The keras pretrained model is a set of classification tasks that was optimized in a different parameter.
  • The keras pretrained model is used in a transfer learning model which was showing the benefits of pretrained models.
  • The list of keras pretrained modules is calling into the deep learning model which represents keras application.
  • Keras pretrained model excepts specific kinds of input preprocessing for the resnet models.

Keras Image Classification Models

Keras application is the deep learning model which was available with the pretrained weights. This module is used in fine-tuning and prediction. Weights are downloaded automatically by using the instantiating model.

Below are the image classification models available in keras as follows:

  • Xception
  • Vgg16
  • Vgg19
  • ResNet50
  • Inceptionv3
  • InceptionResNetV2
  • MobileNetv2
  • DenseNet
  • NasNet
  • MobileNet

All the architecture of keras is compatible with the backbends. The below example shows classify the imagenet classes with ResNet50 as follows.

Code:

tf.keras.applications.ResNet50 (
include_top = True,
weights = "pre-trained",
input_tensor = None,
input_shape = None,
pooling = None,
classes = 2000,
classifier_activation = "model")

Output:

compatible with the backbends

The below example shows extract features from the vgg16 as follows

Code:

tf.keras.applications.vgg16 (
  include_top = True,
  weights = "pre-trained",
  input_tensor = None,
  input_shape = None,
  pooling = None,
  classes = 2000,
  classifier_activation = "model")

Output:

Keras Pre-trained Models 13

The below example shows extract features from the vgg19 as follows.

Code:

tf.keras.applications.vgg19 (
  include_top = True,
  weights = "pre-trained",
  input_tensor = None,
  input_shape = None,
  pooling = None,
   classes = 2000,
   classifier_activation = "model")

Output:

extract features from the vgg19

FAQ

Given below are the FAQs mentioned:

Q1. What is the use of keras pretrained model?

Answer: Pretrained model is nothing but the saved network which was trained by using a larger dataset that was defined in the keras model.

Q2. What is the use of vgg16 model in keras pretrained models?

Answer: The vgg16 model is trained by using imagenet. This model weights and other parameters in that model.

Q3. What is the use of vgg19 model in keras pretrained models?

Answer: The vgg19 model is trained by using imagenet. This model is the same as vgg16 model which was defined in the pretrained model.

Conclusion

Tensor flow is a highly used library for machine learning, it contains keras built-in support. Keras pre-trained models is an image classification model which was used in the python application. Keras will contain ten pre-trained models for the image classification which were trained on the data which was pretrained.

Recommended Articles

This is a guide to Keras Pre-trained Models. Here we discuss the introduction, keras Pre-trained model functions, benefits, and image classification, models. You may also have a look at the following articles to learn more –

  1. Keras Tuner
  2. What is Keras GPU?
  3. Keras Embedding
  4. Keras predict
Primary Sidebar
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Database Management
  • Machine Learning
  • All Tutorials
Certification Courses
  • All Courses
  • Data Science Course - All in One Bundle
  • Machine Learning Course
  • Hadoop Certification Training
  • Cloud Computing Training Course
  • R Programming Course
  • AWS Training Course
  • SAS Training Course

ISO 10004:2018 & ISO 9001:2015 Certified

© 2023 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA Login

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more